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


PHP Model::newFromBuilder方法代码示例

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


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

示例1: initialize

 /**
  * Initialize
  *
  * @return void
  */
 public function initialize()
 {
     if (!$this->initialized) {
         $this->prototype = $this->model->newFromBuilder();
     }
     $this->initialized = true;
 }
开发者ID:naturalweb,项目名称:nwlaravel,代码行数:12,代码来源:ModelResultset.php

示例2: newFromBuilder

 public function newFromBuilder($attributes = array(), $connection = null)
 {
     if ($this->getAttribute($this->getStiClassField())) {
         $class = $this->getAttribute($this->getStiClassField());
         $instance = new $class();
         $instance->exists = true;
         $instance->setRawAttributes((array) $attributes, true);
         return $instance;
     }
     return parent::newFromBuilder($attributes, $connection);
 }
开发者ID:morilog,项目名称:eloquent-sti,代码行数:11,代码来源:SingleTableInheritableModel.php

示例3: newFromBuilder

 public function newFromBuilder($attributes = [], $connection = null)
 {
     if ($this->useSti() && $attributes->{$this->stiClassField}) {
         $class = $attributes->{$this->stiClassField};
         $instance = new $class();
         $instance->exists = true;
         $instance->setRawAttributes((array) $attributes, true);
         return $instance;
     } else {
         return parent::newFromBuilder($attributes);
     }
 }
开发者ID:vidmahovic,项目名称:ep-store,代码行数:12,代码来源:BaseModel.php

示例4: pluck

 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string|null  $key
  * @return \Illuminate\Support\Collection
  */
 public function pluck($column, $key = null)
 {
     $results = $this->toBase()->pluck($column, $key);
     // If the model has a mutator for the requested column, we will spin through
     // the results and mutate the values so that the mutated version of these
     // columns are returned as you would expect from these Eloquent models.
     if (!$this->model->hasGetMutator($column) && !$this->model->hasCast($column) && !in_array($column, $this->model->getDates())) {
         return $results;
     }
     return $results->map(function ($value) use($column) {
         return $this->model->newFromBuilder([$column => $value])->{$column};
     });
 }
开发者ID:sopnopriyo,项目名称:sopnopriyo,代码行数:20,代码来源:Builder.php

示例5: newFromBuilder

 /**
  * Create a new model instance that is existing.
  *
  * @param  array  $attributes
  * @param  string|null  $connection
  * @return static
  */
 public function newFromBuilder($attributes = [], $connection = null)
 {
     $model = parent::newFromBuilder($attributes, $connection);
     $model->fireModelEvent('reconstructed', false);
     /*
     retrieve
     fetch
     obtain
     reconstruct
     rebuild
     */
     return $model;
 }
开发者ID:dfba,项目名称:exteloquent,代码行数:20,代码来源:Model.php

示例6: lists

 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string|null  $key
  * @return \Illuminate\Support\Collection
  */
 public function lists($column, $key = null)
 {
     $results = $this->query->lists($column, $key);
     // If the model has a mutator for the requested column, we will spin through
     // the results and mutate the values so that the mutated version of these
     // columns are returned as you would expect from these Eloquent models.
     if ($this->model->hasGetMutator($column)) {
         foreach ($results as $key => &$value) {
             $fill = [$column => $value];
             $value = $this->model->newFromBuilder($fill)->{$column};
         }
     }
     return collect($results);
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:21,代码来源:Builder.php

示例7: newFromBuilder

 /**
  * !! OVERRIDE ELOQUENT MODEL !!
  * Create a new model instance that is existing.
  *
  * @param  array  $attributes
  * @param  string|null  $connection
  * @return static
  */
 public function newFromBuilder($attributes = [], $connection = null)
 {
     static::stiEnforceChildren();
     // If there isn't a key set, just return the default
     if (!isset($attributes->{static::$stiKey})) {
         return parent::newFromBuilder($attributes, $connection);
     }
     // We create the model based on the keyed type
     $class = static::stiChildren()[$attributes->{static::$stiKey}];
     $model = new $class();
     $model->exists = true;
     /** The rest is copy-and-paste from eloquent */
     $model->setRawAttributes((array) $attributes, true);
     $model->setConnection($connection ?: $this->connection);
     return $model;
 }
开发者ID:oldtimeguitarguy,项目名称:eloquent-single-table-inheritance,代码行数:24,代码来源:StiParent.php

示例8: getModels

 /**
  * Get the hydrated models without eager loading.
  *
  * @param  array  $columns
  * @return array|static[]
  */
 public function getModels($columns = array('*'))
 {
     // First, we will simply get the raw results from the query builders which we
     // can use to populate an array with Eloquent models. We will pass columns
     // that should be selected as well, which are typically just everything.
     $results = $this->query->get($columns);
     $connection = $this->model->getConnectionName();
     $models = array();
     // Once we have the results, we can spin through them and instantiate a fresh
     // model instance for each records we retrieved from the database. We will
     // also set the proper connection name for the model after we create it.
     foreach ($results as $result) {
         $models[] = $model = $this->model->newFromBuilder($result);
         $model->setConnection($connection);
     }
     return $models;
 }
开发者ID:aysenli,项目名称:laravel-admin-1,代码行数:23,代码来源:Builder.php

示例9: newFromBuilder

 /**
  * {@inheritdoc}
  */
 public function newFromBuilder($attributes = array(), $connection = null)
 {
     /** @var Node $instance */
     $instance = parent::newFromBuilder($attributes, $connection);
     $instance->clearAction();
     return $instance;
 }
开发者ID:kjmtrue,项目名称:laravel-nestedset,代码行数:10,代码来源:Node.php

示例10: newFromBuilder

 public function newFromBuilder($attributes = array(), $connection = null)
 {
     $instance = parent::newFromBuilder($attributes);
     $instance->old_parent_id = $instance->parent_id;
     $instance->old_position = $instance->position;
     return $instance;
 }
开发者ID:rexfordkelly-on-php,项目名称:ClosureTable,代码行数:7,代码来源:Entity.php

示例11: newFromBuilder

 /**
  * Create a new model instance that is existing.
  *
  * @param  array  $attributes
  * @return static
  */
 public function newFromBuilder($attributes = array())
 {
     if ($this->isRootModel() and isset($attributes->{static::$table_type_field})) {
         $class = $attributes->{static::$table_type_field};
         $instance = $this->newInstanceOfClass($class, array(), true);
         $instance->setRawAttributes((array) $attributes, true);
         return $instance;
     }
     return parent::newFromBuilder($attributes);
 }
开发者ID:eduacostam,项目名称:laravel-single-table-inheritance,代码行数:16,代码来源:SingleTableInheritance.php


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