本文整理汇总了PHP中Model::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::toArray方法的具体用法?PHP Model::toArray怎么用?PHP Model::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toArray
/**
* @return array
*/
public function toArray()
{
$arr = parent::toArray();
$metadata = $this->getMetadata();
if ($metadata) {
$arr["metadata"] = $metadata;
}
return $arr;
}
示例2: toArray
/**
* @return array
*/
public function toArray()
{
$arr = parent::toArray();
if (array_key_exists("creditor", $arr)) {
unset($arr["creditor"]);
}
if ($this->getCreditor() instanceof Creditor) {
$arr["links"]["creditor"] = $this->getCreditor()->getId();
}
return $arr;
}
示例3: toArray
/**
* @return array
*/
public function toArray()
{
$arr = parent::toArray();
if (array_key_exists("customer", $arr)) {
unset($arr["customer"]);
}
if ($this->getCustomer() instanceof Customer) {
$arr["links"]["customer"] = $this->getCustomer()->getId();
}
if (array_key_exists("mandates", $arr)) {
unset($arr["mandates"]);
}
return $arr;
}
示例4:
/**
* A shorthand getter of the model variables.
*
* If the variable is missing, and error_reporting is turned off (by prepending the call
* with the "@" operator) then the variable is treated as NULL. Otherwise a compilation
* error is raised
*
* @return mixed
*/
function __get($name)
{
Assert::isScalar($name);
if (array_key_exists($name, $this->model->toArray())) {
return $this->model[$name];
} else {
if (!error_reporting()) {
$this->model[$name] = null;
return null;
} else {
Assert::isUnreachable('unknown model variable %s expected within %s view', $name, $this->viewName);
}
}
}
示例5: toArray
/**
* @return array
*/
public function toArray()
{
$arr = parent::toArray();
if (array_key_exists("customerBankAccount", $arr)) {
unset($arr["customerBankAccount"]);
}
if ($this->getCustomerBankAccount() instanceof CustomerBankAccount) {
$arr["links"]["customer_bank_account"] = $this->getCustomerBankAccount()->getId();
}
if (array_key_exists("creditor", $arr)) {
unset($arr["creditor"]);
}
if ($this->getCreditor()) {
$arr["links"]["creditor"] = $this->getCreditor()->getId();
}
return $arr;
}
示例6: updateUser
/**
* @param Model $user
* @param string $realm
*/
static function updateUser($user, $realm = 'admin')
{
if (!session_id()) {
session_start();
}
$app_id = Kennel::getSetting('application', 'id');
$_SESSION["{$app_id}-{$realm}"] = $user->toArray();
self::$user[$realm] = $user;
}
示例7: insertables
/**
* Extract and escape all columns and values from the
* model & return an array containing both strings.
*
* @param Model $model
* @return string[]
*/
protected static function insertables(Model $model)
{
$columns = $values = [];
foreach ($model->toArray() as $column => $value) {
if (self::fillable($model, $column)) {
$columns[] = '`' . $column . '`';
$values[] = static::$db->quote($value);
}
}
return [implode(',', $columns), implode(',', $values)];
}
示例8: loadItemPartial
/**
* Loads an item partial
* @param Model $item
* @return string
*/
private function loadItemPartial($item, $extraData = false)
{
// Convert our item data to a html-safe json object
$data = [];
foreach ($item->toArray() as $key => $value) {
// If the item is json, convert it to an array and filter empty values
if (is_string($value)) {
$jsonArray = json_decode($value, true);
if (json_last_error() == JSON_ERROR_NONE && is_array($jsonArray)) {
$value = array_filter($jsonArray);
}
}
$data[$key] = $value;
}
if ($extraData) {
foreach ($extraData as $key => $value) {
if (array_key_exists($key, $data)) {
continue;
}
$data[$key] = $value;
}
}
$this->vars['modelData'] = htmlspecialchars(json_encode($data));
$partialPath = isset($this->config->default) ? 'item' : $this->config->partial;
$loader = new Twig_Loader_Array(['item' => $this->makePartial($partialPath, ['item' => $item])]);
$twig = new Twig_Environment($loader);
return $this->makePartial('input', ['item' => $item]) . $twig->render('item', $item->toArray());
}
示例9: toArray
public function toArray($element = null)
{
$result = parent::toArray($element);
$result['fullPath'] = $this->getFullPath();
$result['hasClass'] = !!$this->getClass();
return $result;
}
示例10: toArray
public function toArray()
{
$arr = parent::toArray();
if (array_key_exists("mandate", $arr)) {
unset($arr["mandate"]);
}
if ($this->getMandate()) {
$arr["links"]["mandate"] = $this->getMandate()->getId();
}
return $arr;
}
示例11: toArray
public function toArray()
{
return array_merge(parent::toArray(), ['logo' => route('api.payment.logo', $this)]);
}
示例12: modelToArray
/**
* calls the toArray method of models and returns the resulting array
*
* @param Model $model
* @return void
* @author Craig Ulliott
*/
function modelToArray(Model $model)
{
return $model->toArray();
}
示例13: replace
/**
* @param Model $model
* @return Model|null
* @throws Exception
*/
public function replace(Model $model)
{
$rtn = null;
$data = $model->toArray();
$modified = $model->getModified();
$cols = [];
$values = [];
$params = [];
foreach ($modified as $key) {
$cols[] = $key;
$values[] = ':' . $key;
$params[':' . $key] = $data[$key];
}
if (count($cols)) {
$cols = '`' . implode('`, `', $cols) . '`';
$vals = implode(', ', $values);
$query = "REPLACE INTO `{$this->table}` ({$cols}) VALUES ({$vals});";
$stmt = $this->connection->prepare($query);
if ($stmt->execute($params)) {
$modelId = !empty($data[$this->key]) ? $data[$this->key] : $this->connection->lastInsertId();
$this->cacheSet($data[$this->key], null);
$rtn = $this->getByPrimaryKey($modelId, 'write');
$this->cacheSet($modelId, $rtn);
}
}
return $rtn;
}
示例14: toArray
public function toArray()
{
$arr = parent::toArray();
if (array_key_exists("bankAccounts", $arr)) {
unset($arr["bankAccounts"]);
}
return $arr;
}
示例15: toArray
public function toArray()
{
return array_merge(parent::toArray(), ['returnable' => $this->returnable]);
}