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