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


PHP Builder::with方法代码示例

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


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

示例1: iterateAll

 /**
  * @return Generator|Product[]
  */
 public function iterateAll() : Generator
 {
     /** @var Product $product */
     foreach ($this->productResource->with('images')->cursor() as $product) {
         if (!$product->relationLoaded('images')) {
             $product->load('images');
         }
         (yield $product);
     }
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:13,代码来源:ProductRepository.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: buildQuery

 private function buildQuery()
 {
     $this->query = app(get_class($this->model));
     if (!empty($this->fields)) {
         $this->query = $this->query->select($this->fields);
     }
     if (!empty($this->relations)) {
         $this->relations = array_unique($this->relations);
         $this->query = $this->query->with($this->relations);
     }
     if (!empty($this->per_page)) {
         $this->query = $this->query->take($this->per_page);
     }
     if (count($this->conditions)) {
         foreach ($this->conditions as $condition) {
             $this->query = $this->query->where($condition['column'], $condition['operator'], $condition['value'], $condition['boolean']);
         }
     }
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:19,代码来源:DbRepository.php

示例8: search

 public function search($field, $word, $with = [], $perPage = 15)
 {
     $word = strtolower($word);
     $constraint = config('database.default') === 'mysql' ? 'LIKE' : 'ILIKE';
     return $this->query->with($with)->where($field, $constraint, '%' . $word . '%')->paginate($perPage);
 }
开发者ID:rekale,项目名称:sikasir,代码行数:6,代码来源:EloquentRepository.php

示例9: buildIncludes

 /**
  * @param Builder|QueryBuilder $queryBuilder
  * @param array $includes
  */
 protected function buildIncludes($queryBuilder, array $includes)
 {
     $builtIncludes = [];
     foreach ($includes as $includeName => $include) {
         // Support for array includes, example: ['user', 'post']
         // If it's a single dimension array the key will be numeric
         $includeName = is_numeric($includeName) ? $include : $includeName;
         if (empty($include['where']) && empty($include['fields']) && empty($include['order'])) {
             $builtIncludes[] = $includeName;
             continue;
         }
         $builtIncludes[$includeName] = function ($query) use($include) {
             if (isset($include['where'])) {
                 $this->buildWheres($query, $include['where']);
             }
             if (isset($include['fields'])) {
                 $this->buildFields($query, $include['fields']);
             }
             if (isset($include['order'])) {
                 $this->buildOrderBy($query, $include['order']);
             }
         };
     }
     $queryBuilder->with($builtIncludes);
 }
开发者ID:williamoliveira,项目名称:eloquent-array-query-builder,代码行数:29,代码来源:ArrayBuilder.php


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