当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::toArray方法代码示例

本文整理汇总了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;
 }
开发者ID:vouchedfor,项目名称:gocardless-enterprise,代码行数:12,代码来源:MetadataModel.php

示例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;
 }
开发者ID:vouchedfor,项目名称:gocardless-enterprise,代码行数:14,代码来源:CreditorBankAccount.php

示例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;
 }
开发者ID:jonathanstidwillvf,项目名称:gocardless-enterprise,代码行数:17,代码来源:CustomerBankAccount.php

示例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);
         }
     }
 }
开发者ID:phoebius,项目名称:ajax-example,代码行数:23,代码来源:UIViewPresentation.class.php

示例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;
 }
开发者ID:84pixels,项目名称:gocardless-enterprise,代码行数:20,代码来源:Mandate.php

示例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;
 }
开发者ID:rev087,项目名称:kennel,代码行数:13,代码来源:auth.php

示例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)];
 }
开发者ID:nimmneun,项目名称:monomodel,代码行数:18,代码来源:Model.php

示例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());
 }
开发者ID:alvaro-canepa,项目名称:library-1,代码行数:33,代码来源:Widget.php

示例9: toArray

 public function toArray($element = null)
 {
     $result = parent::toArray($element);
     $result['fullPath'] = $this->getFullPath();
     $result['hasClass'] = !!$this->getClass();
     return $result;
 }
开发者ID:jarves,项目名称:jarves,代码行数:7,代码来源:EntryPoint.php

示例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;
 }
开发者ID:84pixels,项目名称:gocardless-enterprise,代码行数:11,代码来源:Payment.php

示例11: toArray

 public function toArray()
 {
     return array_merge(parent::toArray(), ['logo' => route('api.payment.logo', $this)]);
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:4,代码来源:Payment.php

示例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();
}
开发者ID:Tapac,项目名称:hotscot,代码行数:11,代码来源:mvc.php

示例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;
 }
开发者ID:block8,项目名称:database,代码行数:32,代码来源:Store.php

示例14: toArray

 public function toArray()
 {
     $arr = parent::toArray();
     if (array_key_exists("bankAccounts", $arr)) {
         unset($arr["bankAccounts"]);
     }
     return $arr;
 }
开发者ID:84pixels,项目名称:gocardless-enterprise,代码行数:8,代码来源:Customer.php

示例15: toArray

 public function toArray()
 {
     return array_merge(parent::toArray(), ['returnable' => $this->returnable]);
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:4,代码来源:OrderProduct.php


注:本文中的Model::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。