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