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


PHP Model::newQuery方法代码示例

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


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

示例1: addEagerConstraints

 /**
  * Set the constraints for an eager load of the relation.
  *
  * @param  array $models
  *
  * @return void
  */
 public function addEagerConstraints(array $models)
 {
     $this->query->whereNested(function (Builder $inner) use($models) {
         // We will use this query in order to apply constraints to the
         // base query builder
         $outer = $this->parent->newQuery();
         foreach ($models as $model) {
             $outer->setQuery($inner)->orWhereDescendantOf($model);
         }
     });
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:18,代码来源:DescendantsRelation.php

示例2: make

 /**
  * Make a new instance of the entity to query on.
  *
  * @param \Illuminate\Database\Eloquent\Builder $with
  */
 public function make(array $with = [])
 {
     if (method_exists($this->model, 'translations')) {
         if (!in_array('translations', $with)) {
             $with[] = 'translations';
         }
     }
     return $this->model->newQuery()->with($with);
 }
开发者ID:xincap,项目名称:erp,代码行数:14,代码来源:RepositoryImpl.php

示例3: newQuery

 /**
  * @return Builder
  */
 public function newQuery()
 {
     if (is_string($this->modelClass)) {
         return (new $this->modelClass())->newQuery();
     }
     if ($this->modelClass instanceof Model) {
         return $this->modelClass->newQuery();
     }
     return $this->modelClass;
 }
开发者ID:lazychaser,项目名称:shopping,代码行数:13,代码来源:TitlesFromModel.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $grid = new Grid((new GridConfig())->setDataProvider(new EloquentDataProvider($this->userModel->newQuery()))->setColumns([(new FieldConfig('name', 'Логин'))->setCallback(function ($value, $vl) {
         return link_to_route('admin.user.edit', $value, $vl->getSrc());
     })->setSortable(true)->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig('email'))->setSortable(true)->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_EQ)), (new FieldConfig('created_at', 'Дата создания'))->setSortable(true)->setCallback(function (\Carbon\Carbon $value) {
         return $value->toDateString();
     })->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig('roles', 'Роли'))->setCallback(function ($value) {
         $list = $value->lists('display_name');
         if (version_compare(app()->version(), '5.1.0', '>=')) {
             $list = $list->all();
         }
         return implode(', ', $list);
     })]));
     return view('adminPanel::user.index', compact('grid'));
 }
开发者ID:cinject,项目名称:admin-panel,代码行数:20,代码来源:UserController.php

示例5: __construct

 public function __construct(Model $model)
 {
     $this->model = $model;
     $this->query = $model->newQuery();
     $this->parser = new DefaultParser();
     $this->introspector = new EloquentPathIntrospector($this->parser);
 }
开发者ID:realholgi,项目名称:versatile,代码行数:7,代码来源:Builder.php

示例6: newQuery

 public function newQuery()
 {
     $query = parent::newQuery();
     if ($this->includes) {
         return $query->with($this->includes);
     }
     return $query;
 }
开发者ID:iyoworks,项目名称:elegant,代码行数:8,代码来源:Model.php

示例7: newQuery

 public function newQuery($ordered = true)
 {
     $query = parent::newQuery();
     if (empty($ordered)) {
         return $query;
     }
     return $query->orderBy('weight', 'ASC');
 }
开发者ID:viniciusferreira,项目名称:menu,代码行数:8,代码来源:Menu.php

示例8: newQuery

 /**
  * Get a new query builder for the model.
  * set any type of scope you want on this builder in a child class, and it'll
  * keep applying the scope on any read-queries on this model
  *
  * @return Reposed\Builder
  */
 public function newQuery($excludeDeleted = true)
 {
     $builder = parent::newQuery($excludeDeleted);
     if ($this->isSubType()) {
         $builder->where($this->typeField, $this->getClass($this->typeField));
     }
     return $builder;
 }
开发者ID:bepursuant,项目名称:laravel-notification,代码行数:15,代码来源:AbstractEloquent.php

示例9: newQuery

 /**
  * @return $this|\Illuminate\Database\Eloquent\Builder
  */
 public function newQuery()
 {
     $query = parent::newQuery();
     if (substr(\Request::path(), 0, 6) !== 'admin/') {
         return $query->where('is_active', 1);
     }
     return $query;
 }
开发者ID:despark,项目名称:ignicms,代码行数:11,代码来源:I18n.php

示例10: newQuery

 public function newQuery($excludeDeleted = true)
 {
     $raw = '';
     foreach ($this->geofields as $column) {
         $raw .= ' astext(' . $column . ') as ' . $column . ' ';
     }
     return parent::newQuery($excludeDeleted)->addSelect('*', DB::raw($raw));
 }
开发者ID:illuminate3,项目名称:safeOasis,代码行数:8,代码来源:Depot.php

示例11: applyFilters

 /**
  * Apply order and search filters.
  *
  * @return Datagrid
  * @throws \Exception
  */
 public function applyFilters()
 {
     $this->validate();
     $query = $this->searchInEveryColumn($this->model->newQuery());
     $query->orderBy($this->orderBy['column'], $this->orderBy['type']);
     $this->itens = $query->paginate($this->paginate);
     return $this;
 }
开发者ID:muspell,项目名称:crud,代码行数:14,代码来源:Datagrid.php

示例12: search

 /**
  * @param JsonApiRequest $request
  * @return Paginator|Collection|Model|Response|null
  */
 protected function search(JsonApiRequest $request)
 {
     if (!$this->search) {
         return $this->notImplemented();
     }
     $builder = $this->model->newQuery();
     return $this->search->search($builder, $request->getParameters());
 }
开发者ID:cloudcreativity,项目名称:laravel-json-api,代码行数:12,代码来源:EloquentController.php

示例13: newQuery

 public function newQuery($excludeDeleted = true)
 {
     $builder = parent::newQuery($excludeDeleted);
     if (get_class($this) !== $this->getStiBaseClass()) {
         $builder->where($this->getStiClassField(), '=', get_class($this));
     }
     return $builder;
 }
开发者ID:morilog,项目名称:eloquent-sti,代码行数:8,代码来源:SingleTableInheritableModel.php

示例14: newQuery

    /**
     * Redefined for STI pattern
     *
     * @return mixed
     */
    public function newQuery() {
        $builder = parent::newQuery();

        if ($this->sti_field) {
            $builder->where($this->sti_field, get_class($this));
        }

        return $builder;
    }
开发者ID:ananevam,项目名称:wavelaravel,代码行数:14,代码来源:WaveModel.php

示例15: newQuery

 public function newQuery($excludeDeleted = true)
 {
     $class = get_called_class();
     $query = parent::newQuery($excludeDeleted);
     if ($class != 'App\\Post') {
         $query->where($this->table . '.model', '=', $class);
     }
     return $query;
 }
开发者ID:vnsource,项目名称:core,代码行数:9,代码来源:Post.php


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