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


PHP Eloquent::toArray方法代码示例

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


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

示例1: toArray

 public function toArray()
 {
     $results = parent::toArray();
     $results['translated'] = $this->translated();
     // $results['image_dynamic'] = $this->image_dynamic;
     return $results;
 }
开发者ID:huglester,项目名称:pyrocms-helpers,代码行数:7,代码来源:eloquenttranslated.php

示例2: toArray

 public function toArray()
 {
     $array = parent::toArray();
     if (isset($this->variance)) {
         $array['variance'] = $this->variance->toArray();
     }
     return $array;
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:8,代码来源:Color.php

示例3: toArray

 /**
  * Convert the model instance to an array.
  *
  * @return array
  */
 public function toArray()
 {
     $data = parent::toArray();
     $data['id'] = (int) $data['id'];
     $data['completed'] = $this->completed;
     $data['created_at'] = $this->fromDateTime($this->created_at);
     $data['updated_at'] = $this->fromDateTime($this->updated_at);
     return $data;
 }
开发者ID:esmaieldanish,项目名称:laracon-todo-api,代码行数:14,代码来源:Task.php

示例4: toArray

 public function toArray()
 {
     $array = parent::toArray();
     if (!isset($this->visiblePivotAttributes)) {
         return $array;
     }
     foreach ($this->visiblePivotAttributes as $relationship => $attributes) {
         $array[$relationship] = $this->fetchRelationshipPivotAttributes($relationship, $attributes);
     }
     return $array;
 }
开发者ID:denaje,项目名称:laravel-goodies,代码行数:11,代码来源:BaseModel.php

示例5: toArrayFechas

 public function toArrayFechas()
 {
     $array = parent::toArray();
     $esquema = $this->getEsquema();
     foreach ($esquema as $col) {
         if (strtolower(substr($col->Type, 0, 4)) == 'date') {
             $array[$col->Field] = date('d/m/Y', strtotime($this->{$col->Field}));
         }
     }
     return $array;
 }
开发者ID:ateszki,项目名称:clinicasapp,代码行数:11,代码来源:Maestro.php

示例6: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $clean = array();
     foreach ($array as $attr => $value) {
         if ($attr === 'url') {
             $clean[$attr] = $value;
             continue;
         }
         $clean[$attr] = is_numeric($value) ? (int) $value : $value;
     }
     return $clean;
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:13,代码来源:Image.php

示例7: toArray

 public function toArray(User $user = null)
 {
     $arr = parent::toArray();
     $arr['read'] = false;
     if (!isset($user)) {
         unset($arr['user_statuses']);
         return $arr;
     }
     foreach ($arr['user_statuses'] as $status) {
         if ($status['user_id'] == $user->id && $status['status'] == 'read') {
             $arr['read'] = true;
         }
     }
     unset($arr['user_statuses']);
     return $arr;
 }
开发者ID:rhalff,项目名称:vdragon-api,代码行数:16,代码来源:Item.php

示例8: toArray

 public function toArray()
 {
     $array = parent::toArray();
     // return $array;
     if ($this->type == Asset::ASSET_TYPE_IMAGE) {
         $array['url'] = URL::to($this->url());
         $array['base_url'] = URL::to($this->resizeImageURL());
         $array['extension'] = $this->getExtension();
     } else {
         if ($this->type == Asset::ASSET_TYPE_AUDIO) {
             $array['url'] = URL::to($this->getRelativeURL());
         }
     }
     $array['files'] = File::files($this->getRelativePath());
     return $array;
 }
开发者ID:vanderlin,项目名称:halp,代码行数:16,代码来源:Asset.php

示例9: toChangesArray

 public function toChangesArray(TimesheetEvent $other)
 {
     $attributes_old = parent::toArray();
     $attributes_new = $other->toArray();
     $skip_keys = ['id' => 1, 'created_at' => 1, 'updated_at' => 1, 'deleted_at' => 1, 'org_data' => 1, 'update_data' => 1];
     $zeroisempty_keys = ['discount' => 1];
     $result = [];
     // Find all the values that where changed or deleted
     foreach ($attributes_old as $key => $value) {
         // Skip null values, keys we don't care about and 0 value keys that means they are not used
         if (empty($value) || isset($skip_keys[$key]) || isset($zeroisempty_keys[$key]) && $value) {
             continue;
         }
         // Compare values if it exists in the new array
         if (isset($attributes_new[$key]) || array_key_exists($key, $attributes_new)) {
             if ($value instanceof \DateTime && $attributes_new[$key] instanceof \DateTime) {
                 if ($value != $attributes_new[$key]) {
                     $result[$key] = $attributes_new[$key]->format("Y-m-d H:i:s");
                 }
             } elseif ($value instanceof \DateTime && is_string($attributes_new[$key])) {
                 if ($value->format("Y-m-d H:i:s") != $attributes_new[$key]) {
                     $result[$key] = $attributes_new[$key];
                 }
             } elseif (is_string($value) && $attributes_new[$key] instanceof \DateTime) {
                 if ($attributes_new[$key]->format("Y-m-d H:i:s") != $value) {
                     $result[$key] = $attributes_new[$key]->format("Y-m-d H:i:s");
                 }
             } elseif ($value != $attributes_new[$key]) {
                 $result[$key] = $attributes_new[$key];
             }
         } else {
             $result[$key] = null;
         }
     }
     // Find all the values that where deleted
     foreach ($attributes_new as $key => $value) {
         if (isset($skip_keys[$key])) {
             continue;
         }
         if (!isset($attributes_old[$key])) {
             $result[$key] = $value;
         }
     }
     return $result;
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:45,代码来源:TimesheetEvent.php

示例10: getValues

 /**
  * Gets the picked values for the entered fields
  *
  * @param  array    $fields
  * @param  Eloquent $model
  * @return array
  */
 protected function getValues($fields, $model, $page)
 {
     $values = array_except($model->toArray(), ['id', 'created_at', 'updated_at', 'deleted_at']);
     foreach ($fields as $field) {
         foreach ($field->picks as $modelAttribute => $fieldAttribute) {
             $values[$modelAttribute] = $field->values->get($fieldAttribute, null);
         }
     }
     if ($this->Schema->hasColumn($model->getTable(), 'page_version_id')) {
         $values['page_version_id'] = $page['page_version_id'];
     }
     if ($this->Schema->hasColumn($model->getTable(), 'language_id')) {
         $values['language_id'] = $page['language_id'];
     }
     return $values;
 }
开发者ID:devisephp,项目名称:cms,代码行数:23,代码来源:ModelManager.php

示例11: toArray

 public function toArray()
 {
     $array = parent::toArray();
     // small modifications
     $array['unixtime'] = strtotime($array['created_at']);
     $array['edited'] = strtotime($array['updated_at']);
     $array['timeago'] = time_ago($array['created_at']);
     $array['time'] = modding_link(rtrim($array['time']));
     $array['text'] = linkify(modding_link($array['text']));
     $array['icon'] = $array['is_resolved'] ? $this->icons['resolved'] : (@$this->icons[$array['type']] ?: '');
     // renames
     $array['id'] = $array['item_id'];
     $array['beatmap'] = $array['beatmap_id'];
     $array['resolved'] = $array['is_resolved'];
     // unsets
     unset($array['item_id']);
     unset($array['beatmapset_id']);
     unset($array['beatmap_id']);
     unset($array['is_resolved']);
     unset($array['created_at']);
     unset($array['updated_at']);
     if (!$array['deleted_at']) {
         unset($array['deleted_at']);
     }
     return $array;
 }
开发者ID:nanaya,项目名称:osu-web,代码行数:26,代码来源:Mod.php

示例12: toArray

 /**
  *   Include link to annotation when converted to array
  * 
  *   @param null
  * @return parent::toArray()
  */
 public function toArray()
 {
     $this->link = $this->getLink();
     return parent::toArray();
 }
开发者ID:iaincollins,项目名称:madison,代码行数:11,代码来源:Comment.php

示例13: toArray

 public function toArray()
 {
     $array = parent::toArray();
     // small modifications
     $array["unixtime"] = strtotime($array["created_at"]);
     $array["edited"] = strtotime($array["updated_at"]);
     $array["timeago"] = time_ago($array["created_at"]);
     $array["time"] = modding_link(rtrim($array["time"]));
     $array["text"] = linkify(modding_link($array["text"]));
     $array["icon"] = $array["is_resolved"] ? $this->icons["resolved"] : (@$this->icons[$array["type"]] ?: "");
     // renames
     $array["id"] = $array["item_id"];
     $array["beatmap"] = $array["beatmap_id"];
     $array["resolved"] = $array["is_resolved"];
     // unsets
     unset($array["item_id"]);
     unset($array["beatmapset_id"]);
     unset($array["beatmap_id"]);
     unset($array["is_resolved"]);
     unset($array["created_at"]);
     unset($array["updated_at"]);
     if (!$array["deleted_at"]) {
         unset($array["deleted_at"]);
     }
     return $array;
 }
开发者ID:WiiPlayer2,项目名称:osu-web,代码行数:26,代码来源:Mod.php

示例14: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['url'] = URL::to('/spots/tags/' . $this->slug);
     return $array;
 }
开发者ID:vanderlin,项目名称:halp,代码行数:6,代码来源:Tag.php

示例15: toArray

 public function toArray()
 {
     $array = parent::toArray();
     $array['existsPaid'] = $this->existsPaid;
     $array['tokenExists'] = $this->tokenExists;
     return $array;
 }
开发者ID:evo9,项目名称:dryharder,代码行数:7,代码来源:Customer.php


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