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


PHP Model::getModel方法代码示例

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


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

示例1: search

 /**
  * @param Model|Builder $model
  * @return Model
  */
 public function search($model)
 {
     if ($model instanceof SearchableModel) {
         $this->fieldConfig = $model->searchableFields();
         $this->primaryTable = $model->getTable();
     }
     if ($model instanceof Relation) {
         $this->primaryTable = $model->getModel()->getTable();
         $this->fieldConfig = $model->getModel()->searchableFields();
         $this->apply($model->getQuery());
         return $model;
     }
     return $this->apply($model);
 }
开发者ID:theHarvester,项目名称:QURI-Laravel,代码行数:18,代码来源:QuriRequest.php

示例2: generateFromRelations

 public function generateFromRelations()
 {
     $this->parent = $this->query->getModel();
     foreach (explode('.', $this->relations) as $index => $relation) {
         $this->index = $index;
         $this->relation = call_user_func(array($this->parent, $relation));
         $this->related = $this->relation->getRelated();
         if ($this->nested) {
             if (!array_key_exists($this->index, $this->ons)) {
                 $this->ons[$this->index] = [];
             }
             if (!array_key_exists($this->index, $this->conditions)) {
                 $this->conditions[$this->index] = [];
             }
         }
         if ($this->relation instanceof BelongsTo) {
             $this->generateJoinFromBelongsTo($this->relation);
         } elseif ($this->relation instanceof BelongsToMany) {
             $this->generateJoinFromBelongsToMany($this->relation);
         } elseif ($this->relation instanceof HasOneOrMany) {
             $this->generateJoinFromHasOneOrMany($this->relation);
         }
         $this->parent = $this->relation->getRelated();
     }
     if ($this->addNullCondition) {
         if ($this->relation instanceof BelongsTo) {
             $this->generateNullConditionFromBelongsTo($this->relation);
         } elseif ($this->relation instanceof BelongsToMany) {
             $this->generateNullConditionFromBelongsToMany();
         } elseif ($this->relation instanceof HasOneOrMany) {
             $this->generateNullConditionFromHasOneOrMany($this->relation);
         }
     }
 }
开发者ID:brazenvoid,项目名称:better-eloquent,代码行数:34,代码来源:JoinBuilder.php

示例3: where

 /**
  * Sets the where clause to the current entity. 
  *
  * @param array|Closure $query
  * @param bool $append
  * @return self
  */
 public function where($query, $append = false)
 {
     $entity = $this->entity;
     switch ($query) {
         case $query instanceof Closure:
             // Overwrite: Strip down the Builder to a Model when
             // the current entity has a where clause and $append is false
             if (!$append && $entity instanceof Builder) {
                 $entity = $this->entity->getModel();
             }
             // Supplied callback return to be attached
             try {
                 $entity = call_user_func($query, $entity);
                 if (!$entity instanceof Builder) {
                     throw new InvalidCallbackReturn();
                 }
             } catch (InvalidCallbackReturn $e) {
                 //Retain the current entity as it was before this method's call.
                 $entity = $this->entity;
             }
             // Assign the entity with the newly attached where clause
             $this->entity = $entity;
             break;
         case is_array($query):
             foreach ($query as $clause) {
                 $this->entity->where($clause);
             }
             break;
     }
     return $this;
 }
开发者ID:prjkt,项目名称:repofuck,代码行数:38,代码来源:Repofuck.php

示例4: refresh

 /**
  *
  */
 protected function refresh()
 {
     if (!$this->model instanceof EloquentModel) {
         $this->model = $this->model->getModel();
     }
     $this->model = $this->model->newInstance();
     $this->criteria = new Collection();
 }
开发者ID:ablunier,项目名称:laravel-database,代码行数:11,代码来源:Repository.php

示例5: getFillable

 /**
  * Get the fillable attributes for the model.
  *
  * @return array
  */
 protected function getFillable()
 {
     return $this->model instanceof Builder ? $this->model->getModel()->getFillable() : $this->model->getFillable();
 }
开发者ID:propaganistas,项目名称:laravel-repository,代码行数:9,代码来源:Repository.php

示例6: scopeWhereInSubQuery

 /**
  * @param EloquentBuilder|QueryBuilder|Model $query
  * @param string $column
  * @param EloquentBuilder|QueryBuilder|Model $subQuery
  * @param string $subQueryColumn
  *
  * @return QueryBuilder
  */
 public function scopeWhereInSubQuery($query, $column, $subQuery, $subQueryColumn)
 {
     if (!Str::contains($column, '.')) {
         /** @var Model|BetterEloquentTrait $model */
         $model = $query->getModel();
         $column = $model->getField($column);
     }
     $subQuery = $subQuery->toSubQuery($subQueryColumn, true);
     return $query->whereIn($column, $subQuery);
 }
开发者ID:brazenvoid,项目名称:better-eloquent,代码行数:18,代码来源:BetterEloquentTrait.php


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