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


PHP Model::toArray方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::toArray方法的具体用法?PHP Model::toArray怎么用?PHP Model::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toArray

 public function toArray($user_id = null)
 {
     $array = parent::toArray();
     $array['supporter_counter'] = (int) Redis::get('supporter_counter:' . $this->id);
     $array['is_supported'] = (int) Redis::zscore('issue_supporters:' . $this->id, $user_id) > 0 ? 1 : 0;
     return $array;
 }
开发者ID:istatease-dev,项目名称:api,代码行数:7,代码来源:Issue.php

示例2: authorizeForResults

 /**
  * @param Model $model
  * @param       $column
  * @return mixed
  */
 protected function authorizeForResults(Model $model, $column)
 {
     if (!array_key_exists($column, $model->toArray())) {
         return $this->authorize('add_activity', $model);
     }
     return $this->authorize('edit_activity', $model);
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:12,代码来源:AuthorizesByRequestType.php

示例3: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['user'] = $this->user;
     $array['lista'] = $this->lista;
     return $array;
 }
开发者ID:Truexxangusxx,项目名称:Servicio_laravel,代码行数:7,代码来源:Atencion.php

示例4: __construct

 public function __construct(\Illuminate\Database\Eloquent\Model $extra)
 {
     $this->common = $extra->toArray();
     $this->composition = $extra->composition->toArray();
     $this->atmosphere = $extra->atmosphere->toArray();
     $this->orbit = $extra->orbit->toArray();
 }
开发者ID:Qeenslet,项目名称:elite-lara,代码行数:7,代码来源:planetExtraInfo.php

示例5: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['opened_issue_counter'] = (int) Redis::get('user_opened_issue_counter:' . $this->id);
     $array['supported_issue_counter'] = (int) Redis::get('user_supported_issue_counter:' . $this->id);
     return $array;
 }
开发者ID:istatease-dev,项目名称:api,代码行数:7,代码来源:User.php

示例6: saving

 public function saving(Model $model)
 {
     $validator = Validator::make($model->toArray(), ['parent_id' => 'integer', 'name' => 'required']);
     if ($validator->fails()) {
         throw new \RuntimeException('Validate Fails');
     }
 }
开发者ID:vergil-lai,项目名称:node-categoires,代码行数:7,代码来源:Observer.php

示例7: toArray

 public function toArray()
 {
     $data = parent::toArray();
     if (!empty($data['photos'])) {
         $data['photos'] = $this->processPhotos($data['photos']);
     }
     $data['age'] = false;
     if (!empty($data['bdate'])) {
         $bdate = explode('.', $data['bdate']);
         if (count($bdate) >= 3) {
             $bdate = new \DateTime($bdate[2] . '-' . $bdate[1] . '-' . $bdate[0]);
             $now = new \DateTime();
             $diff = $now->diff($bdate);
             $year = $diff->y;
             $age = trans_choice('main.age', $year, [], 'message', 'ru');
             $data['age'] = $age;
         }
     }
     if ($data['age'] == false) {
         $year = rand(18, 25);
         $age = trans_choice('main.age', $year, [], 'message', 'ru');
         $data['age'] = $age;
     }
     return $data;
 }
开发者ID:stels-cs,项目名称:tinder-olega,代码行数:25,代码来源:VKUsers.php

示例8: toArray

 public function toArray()
 {
     $data = parent::toArray();
     $data['sizes'] = $this->sizeURLs();
     $data['url'] = $this->URL('m');
     return $data;
 }
开发者ID:joshhudnall,项目名称:beancounter,代码行数:7,代码来源:Media.php

示例9: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['permission_role'] = $this->permission_role;
     $array['user_detail'] = $this->user;
     $array['role_detail'] = $this->roles;
     return $array;
 }
开发者ID:ardiqghenatya,项目名称:koptel2,代码行数:8,代码来源:RoleUser.php

示例10: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $text = json_decode($this->text, true);
     $array['text'] = $text['message'];
     $array['log_data'] = $text['data'];
     return $array;
 }
开发者ID:ardiqghenatya,项目名称:koptel2,代码行数:8,代码来源:ActivityLog.php

示例11: toArray

 public function toArray($options = 0)
 {
     //return parent::toArray();
     if ($options === 'default') {
         return parent::toArray();
     }
     return $this->toArrayCamel();
 }
开发者ID:jgraffite,项目名称:snake2camel,代码行数:8,代码来源:Eloquent.php

示例12: toArray

 /**
  * Convert the model instance to an array.
  *
  * @return array
  */
 public function toArray()
 {
     $data = parent::toArray();
     if (isset($data['date']) && $data['date']) {
         $data['date'] = $this->date->format('Y-m-d');
     }
     return $data;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:13,代码来源:Project.php

示例13: getData

 /**
  * Retrieve data to validate.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @return array
  */
 public function getData()
 {
     // If a model has been set, it'll take priority
     if (!empty($this->model)) {
         return $this->model->toArray();
     }
     return $this->data;
 }
开发者ID:nodes-php,项目名称:validation,代码行数:15,代码来源:AbstractValidator.php

示例14: formatEloquentModel

 /**
  * Format an Eloquent model.
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  *
  * @return string
  */
 public function formatEloquentModel($model)
 {
     $key = str_singular($model->getTable());
     if (!$model::$snakeAttributes) {
         $key = camel_case($key);
     }
     return $this->encode([$key => $model->toArray()]);
 }
开发者ID:joselfonseca,项目名称:api,代码行数:15,代码来源:Json.php

示例15: toArray

 public function toArray($outputAttributes = null)
 {
     $attributes = parent::toArray();
     if (is_array($outputAttributes)) {
         $attributes = array_intersect_key($attributes, array_flip($outputAttributes));
     }
     return $attributes;
 }
开发者ID:bobcui,项目名称:manga-php,代码行数:8,代码来源:Model.php


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