當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。