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


PHP Builder::with方法代码示例

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


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

示例1: byPublicId

 /**
  * @param int $publicId
  *
  * @return Order
  */
 public function byPublicId(int $publicId) : Order
 {
     /** @var Order $order */
     $order = $this->orderResource->with(self::DEFAULT_RELATIONS)->where('id', '=', Order::privateId($publicId))->first();
     if ($order instanceof Order) {
         return $order;
     }
     return new Order();
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:14,代码来源:OrderRepository.php

示例2: withRelatedCriterion

 public function withRelatedCriterion(QueryBuilder $query)
 {
     if ($this->related === null) {
         throw new \RuntimeException('No relationships defined in the repository. Eloquent does ' . 'not support reading relationships from the Model. Related ' . 'models must be defined in the $related property of the ' . 'repository.');
     }
     return $query->with($this->related);
 }
开发者ID:monospice,项目名称:spicy-repositories,代码行数:7,代码来源:BasicCriteria.php

示例3: eagerLoad

 /**
  * Add relationships to the query builder to eager load
  *
  * @return $this
  */
 protected function eagerLoad()
 {
     foreach ($this->with as $relation) {
         $this->query->with($relation);
     }
     return $this;
 }
开发者ID:Okipa,项目名称:una.app,代码行数:12,代码来源:BaseRepository.php

示例4: table

 /**
  * Returns a new Issue table.
  *
  * @param Issue|Builder $issue
  * @param array         $with
  * @param Closure       $closure
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table($issue, array $with = ['users', 'labels'], Closure $closure = null)
 {
     $label = request('label');
     // Filter issues with the specified request label.
     $issue->with($with)->label($label)->latest();
     return $this->table->of('issues', function (TableGrid $table) use($issue, $closure) {
         if ($closure instanceof Closure) {
             $table = call_user_func($closure, $table, $issue);
         } else {
             $table->with($issue)->paginate($this->perPage);
         }
         $table->sortable(['title', 'description', 'created_at']);
         $table->searchable(['title', 'description']);
         $table->column('status', function (Column $column) {
             $column->label = '';
             $column->value = function (Issue $issue) {
                 return $issue->present()->statusIcon();
             };
             $column->attributes(function () {
                 return ['width' => '30'];
             });
         });
         $table->column('title', function (Column $column) {
             return $this->tableTitle($column);
         });
     });
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:36,代码来源:IssuePresenter.php

示例5: applyResourceOptions

 /**
  * Apply resource options to a query builder
  * @param  Builder $query
  * @param  array  $options
  * @return Builder
  */
 protected function applyResourceOptions(Builder $query, array $options = [])
 {
     if (!empty($options)) {
         extract($options);
         if (isset($includes)) {
             if (!is_array($includes)) {
                 throw new InvalidArgumentException('Includes should be an array.');
             }
             $query->with($includes);
         }
         if (isset($filter_groups)) {
             $filterJoins = $this->applyFilterGroups($query, $filter_groups);
         }
         if (isset($sort)) {
             if (!is_array($sort)) {
                 throw new InvalidArgumentException('Sort should be an array.');
             }
             if (!isset($filterJoins)) {
                 $filterJoins = [];
             }
             $sortingJoins = $this->applySorting($query, $sort, $filterJoins);
         }
         if (isset($limit)) {
             $query->limit($limit);
         }
         if (isset($page)) {
             $query->offset($page * $limit);
         }
     }
     return $query;
 }
开发者ID:esbenp,项目名称:bruno,代码行数:37,代码来源:EloquentBuilderTrait.php

示例6: scopeWithUserMessages

 /**
  * Returns all the registered users.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeWithUserMessages(Builder $query)
 {
     return $query->with(['user.messages' => function ($query) {
         return $query->whereReceptorId(Auth::user()->id)->orderBy('created_at', 'asc');
     }, 'user.receivedMessages' => function ($query) {
         return $query->whereAuthorId(Auth::user()->id)->orderBy('created_at', 'asc');
     }]);
 }
开发者ID:NuestraMarca,项目名称:tenderos,代码行数:14,代码来源:Session.php

示例7: with

 /**
  * Load relations
  *
  * @param array|string $relations
  * @return $this
  */
 public function with($relations)
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('with', $relations);
     $this->model = $this->model->with($relations);
     return $this;
 }
开发者ID:sandeeprajoria,项目名称:Housekeeper,代码行数:15,代码来源:BaseRepository.php

示例8: getAll

 /**
  * Retrive all notifications, not read
  * in first.
  * You can also limit the number of
  * Notifications if you don't, it will get all
  *
  * @param           $to_id
  * @param           $entity
  * @param  null     $limit
  * @param  int|null $paginate
  * @param  string   $orderDate
  * @param Closure   $filterScope
  * @return mixed
  */
 public function getAll($to_id, $entity, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null)
 {
     $query = $this->notification->with('body', 'from')->wherePolymorphic($to_id, $entity)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     $query = $this->applyFilter($filterScope, $query);
     if (is_int(intval($paginate)) && $paginate) {
         return $query->paginate($limit);
     }
     return $query->get();
 }
开发者ID:computerfr33k,项目名称:Notifynder,代码行数:23,代码来源:NotificationRepository.php

示例9: getAll

 /**
  * Retrive all notifications, not read
  * in first.
  * You can also limit the number of
  * Notifications if you don't, it will get all
  *
  * @param         $to_id
  * @param         $entity
  * @param  null   $limit
  * @param  bool   $paginate
  * @param  string $orderDate
  * @return mixed
  */
 public function getAll($to_id, $entity, $limit = null, $paginate = false, $orderDate = 'desc')
 {
     $result = $this->notification->with('body', 'from')->wherePolymorphic($to_id, $entity)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     // if the limit is set
     if (!is_null($limit)) {
         $result->limit($limit);
     }
     return $result->get();
 }
开发者ID:naimkhalifa,项目名称:Notifynder,代码行数:22,代码来源:NotificationRepository.php

示例10: eagerLoadRelations

 /**
  * @return $this
  */
 protected function eagerLoadRelations()
 {
     if (isset($this->with)) {
         foreach ($this->with as $relation) {
             $this->model->with($relation);
         }
     }
     return $this;
 }
开发者ID:jonphipps,项目名称:Repositories,代码行数:12,代码来源:Repository.php

示例11: constraintBuilder

 /**
  * {@inheritdoc}
  */
 public function constraintBuilder(EloquentBuilder $builder, array $options)
 {
     if ($relations = $this->eagerLoads(array_get($options, 'simple'))) {
         $builder->with($relations);
     }
     $query = $builder->getQuery();
     if ($value = array_get($options, 'order', $this->defaultOrder)) {
         $this->order($query, $value);
     }
 }
开发者ID:guratr,项目名称:cruddy,代码行数:13,代码来源:Collection.php

示例12: scopeWithRevisionsWithoutData

 /**
  * @param Builder|\Illuminate\Database\Query\Builder $builder
  * @param null                                       $columns
  *
  * @return mixed
  */
 public function scopeWithRevisionsWithoutData($builder, $columns = null)
 {
     $columns = $columns ?: ['id', 'event', 'revisionable_type', 'revisionable_id', 'user_id', 'created_at', 'updated_at'];
     $builder->with(['revisions' => function ($q) use($columns) {
         /** @var Builder|\Illuminate\Database\Query\Builder $q */
         $q->select($columns);
         $q->with('user');
     }]);
     return $builder;
 }
开发者ID:vluzrmos,项目名称:simple-revisions,代码行数:16,代码来源:RevisionableTrait.php

示例13: scopeWithTranslation

 /**
  * This scope eager loads the translations for the default and the fallback locale only.
  * We can use this as a shortcut to improve performance in our application.
  *
  * @param Builder $query
  */
 public function scopeWithTranslation(Builder $query)
 {
     $query->with(['translations' => function ($query) {
         $query->where(function ($query) {
             $query->where($this->getTranslationsTable() . '.' . $this->getLocaleKey(), $this->locale());
             if ($this->useFallback()) {
                 return $query->orWhere($this->getTranslationsTable() . '.' . $this->getLocaleKey(), $this->getFallbackLocale($this->locale()))->orWhere($this->getTranslationsTable() . '.' . $this->getLocaleKey(), $this->getFallbackLocale());
             }
         });
     }]);
 }
开发者ID:kitbs,项目名称:vinfo,代码行数:17,代码来源:TranslatableSortable.php

示例14: scopeWithEmbed

 /**
  * Otimiza as query do Eloquent adicionando
  * Eager Loading do Eloquent
  * @param string cidade,cidade.estado
  * @return \Eloquent
  */
 protected function scopeWithEmbed($embed = null)
 {
     $embed = is_null($embed) ? \Input::get('include') : $embed;
     $requestedEmbeds = explode(',', $embed);
     $possibleRelationships = (array) $this->model->relationships;
     $eagerLoad = array_values(array_intersect($possibleRelationships, $requestedEmbeds));
     if (!empty($eagerLoad)) {
         \Log::info($eagerLoad);
         $this->query->with($eagerLoad);
     }
     return $this;
 }
开发者ID:gdgfoz,项目名称:codelab-todo-api,代码行数:18,代码来源:BaseRepository.php

示例15: getStack

 /**
  * Retrive all notifications, in a stack.
  * You can also limit the number of
  * Notifications if you don't, it will get all.
  *
  * @param           $stackId
  * @param  null     $limit
  * @param  int|null $paginate
  * @param  string   $orderDate
  * @param Closure   $filterScope
  * @return mixed
  */
 public function getStack($stackId, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null)
 {
     $query = $this->notification->with('body', 'from', 'to')->byStack($stackId)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     if ($limit && !$paginate) {
         $query->limit($limit);
     }
     $query = $this->applyFilter($filterScope, $query);
     if (is_int(intval($paginate)) && $paginate) {
         return $query->paginate($limit);
     }
     return $query->get();
 }
开发者ID:fenos,项目名称:notifynder,代码行数:24,代码来源:NotificationRepository.php


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