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


PHP Builder::select方法代码示例

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


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

示例1: relatedEventsOutcome

 /**
  * @param EloquentBuilder $query
  */
 private function relatedEventsOutcome(EloquentBuilder $query)
 {
     $query->orWhere(function (EloquentBuilder $query) {
         $query->where('entity_type', 'App\\Outcome')->whereIn('entity_id', function (QueryBuilder $query) {
             $query->select('id')->from('outcomes')->whereIn('envelope_id', function (QueryBuilder $query) {
                 $query->select('id')->from('envelopes')->where('account_id', $this->id);
             });
         });
     });
 }
开发者ID:simondubois,项目名称:budget,代码行数:13,代码来源:AccountRelatedEvents.php

示例2: apply

 /**
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->join('post_translations', function ($join) {
         $join->on('posts.id', '=', 'post_translations.post_id')->where('post_translations.locale', '=', app()->getLocale())->where('post_translations.publish_at', '<', Carbon::now()->format('Y-m-d H:i:s'));
     });
     $builder->select(['posts.*']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:11,代码来源:PostScopeFront.php

示例3: find

 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     // Hide discussions which have tags that the user is not allowed to see.
     $query->whereNotExists(function ($query) use($actor) {
         return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
     });
 }
开发者ID:lazyboywu,项目名称:edufunbbs,代码行数:11,代码来源:DiscussionPolicy.php

示例4: scopeWithRelatedTranslations

 public function scopeWithRelatedTranslations(Builder $query, $relation, $andFields = [])
 {
     $model = $relation->getRelated();
     $withFallback = $model->usePublicFallback();
     $translatedAttributes = array_merge($model->translatedAttributes, $andFields);
     $translatedAttributes = array_map(function ($attribute) use($model) {
         return $model->getPublicTranslationsTable() . '.' . $attribute . ' AS ' . $model->getPublicTranslationsTable() . '_' . $attribute;
     }, $translatedAttributes);
     $query->withTranslations();
     $translatedAttributes = array_merge((array) $query->getQuery()->columns, $translatedAttributes);
     $query->select($translatedAttributes)->leftJoin($model->getPublicTranslationsTable(), $model->getPublicTranslationsTable() . '.' . $model->getRelationKey(), '=', $relation->getQualifiedForeignKey())->where(function ($query) use($model, $withFallback) {
         $query->where($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->publicLocale());
         if ($withFallback) {
             $query->orWhere(function (Builder $q) use($model) {
                 $q->where($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->getPublicFallbackLocale($model->publicLocale()))->whereNotIn($model->getPublicTranslationsTable() . '.' . $model->getRelationKey(), function (QueryBuilder $q) use($model) {
                     $q->select($model->getPublicTranslationsTable() . '.' . $model->getRelationKey())->from($model->getPublicTranslationsTable())->where($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->publicLocale());
                 });
             })->orWhere(function (Builder $q) use($model) {
                 $q->where($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->getPublicFallbackLocale())->whereNotIn($model->getPublicTranslationsTable() . '.' . $model->getRelationKey(), function (QueryBuilder $q) use($model) {
                     $q->select($model->getPublicTranslationsTable() . '.' . $model->getRelationKey())->from($model->getPublicTranslationsTable())->where($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->getPublicFallbackLocale($model->publicLocale()))->orWhere($model->getPublicTranslationsTable() . '.' . $model->getLocaleKey(), $model->publicLocale());
                 });
             });
         }
     });
 }
开发者ID:kitbs,项目名称:vinfo,代码行数:25,代码来源:TranslatableSortable.php

示例5: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->join('product_translations', function ($join) {
         $join->on('products.id', '=', 'product_translations.product_id')->where('product_translations.locale', '=', app()->getLocale())->where('product_translations.published', '=', 1);
     });
     $builder->select(['products.*']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:12,代码来源:ProductScopeFront.php

示例6: find

 /**
  * @param $id
  * @param bool $orFail
  * @return Model|null
  *
  * method attempts to find record with given id
  */
 public function find($id, $orFail = false)
 {
     if ($this->cache) {
         $this->cacheKey = ($this->onlyVisible ? '-' : '+') . ($this->onlyAuthored ? '-' : '+') . "{$this->baseName}.find[{$id}]";
         if ($cache = Cache::get($this->cacheKey)) {
             $this->clearFilters();
             return $cache === 'null' ? null : $cache;
         }
     }
     $this->model = new $this->modelClass();
     $table = $this->model->getTable();
     $this->model = $this->model->newQuery();
     $this->model->select("{$table}.*");
     $this->prepare($this->model);
     if ($this->onlyVisible) {
         $this->filterVisible($this->model);
     }
     if ($this->onlyAuthored) {
         $this->filterAuthored($this->model);
     }
     $this->filter($this->model, $this->filters);
     $this->model->where($table . '.' . $this->identifier, '=', $id);
     $result = $orFail ? $this->model->firstOrFail() : $this->model->first();
     $this->storeToCache($result);
     $this->clearFilters();
     return $result;
 }
开发者ID:pointer-ba,项目名称:bundle,代码行数:34,代码来源:Repository.php

示例7: getRelationCountQueryForSelfRelation

 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationCountQueryForSelfRelation(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $query->from($query->getModel()->getTable() . ' as ' . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->getPlainForeignKey(), '=', new Expression($key));
 }
开发者ID:nsoimaru,项目名称:Laravel51-starter,代码行数:14,代码来源:HasOneOrMany.php

示例8: scopeExcludeFromFind

 /**
  * Exclude from find
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeExcludeFromFind(Builder $query)
 {
     if (isset($this->excludedFromFind) == TRUE && is_array($this->excludedFromFind) == TRUE) {
         return $query->select(array_diff(Schema::getColumnListing($this->table), $this->excludedFromFind));
     } else {
         return $query;
     }
 }
开发者ID:jdrda,项目名称:olapus,代码行数:13,代码来源:AdminModelTrait.php

示例9: rememberForever

 /**
  * Store the result on cache forever
  *
  * @param array $columns
  * @return mixed
  */
 public function rememberForever(array $columns = ['*'])
 {
     $this->applyCriteria();
     $this->builder->select($columns);
     return Cache::rememberForever($this->generateCacheKey(), function () use($columns) {
         return $this->all($columns);
     });
 }
开发者ID:renatogcarvalho,项目名称:feeder,代码行数:14,代码来源:Repository.php

示例10: select

 /**
  * Attach the name of the table to each column of the select if possible
  *
  * @param array $columns
  * @return mixed
  */
 public function select($columns = ['*'])
 {
     $columns = !is_array($columns) ? [$columns] : $columns;
     foreach ($columns as $key => $column) {
         $columns[$key] = $this->getModelTableColumn($column);
     }
     return parent::select($columns);
 }
开发者ID:Jchedev,项目名称:laravel-evolved,代码行数:14,代码来源:Builder.php

示例11: count

 /**
  * Returns the count for a countable parameter, given the query provided
  *
  * @param string                   $name
  * @param EloquentBuilder          $query
  * @param CountableFilterInterface $filter
  * @return array
  */
 public function count($name, $query, CountableFilterInterface $filter)
 {
     // if the columnname is not set, assume an id field based on a table name
     $columnName = empty($this->columnName) ? $name : $this->columnName;
     if (!$this->includeEmpty) {
         $query->whereNotNull($columnName);
     }
     return $query->select("{$columnName} AS {$this->columnAlias}", DB::raw("{$this->countRaw} AS {$this->countAlias}"))->groupBy($columnName)->pluck($this->countAlias, $this->columnAlias);
 }
开发者ID:czim,项目名称:laravel-filter,代码行数:17,代码来源:SimpleDistinctValue.php

示例12: excludeCriterion

 public function excludeCriterion(QueryBuilder $query, $columns)
 {
     $columns = static::getArgumentsArray($columns, func_get_args());
     // Get the attributes of the model and filter out all but specified
     $schema = $query->getQuery()->getConnection()->getSchemaBuilder();
     $allColumns = $schema->getColumnListing($query->getModel()->getTable());
     $difference = array_diff($allColumns, $columns);
     return $query->select($difference);
 }
开发者ID:monospice,项目名称:spicy-repositories,代码行数:9,代码来源:BasicCriteria.php

示例13: getRelationQuery

 /**
  * @param EloquentBuilder $query
  * @param EloquentBuilder $parent
  * @param array $columns
  *
  * @return mixed
  */
 public function getRelationQuery(EloquentBuilder $query, EloquentBuilder $parent, $columns = ['*'])
 {
     $query->select($columns);
     $table = $query->getModel()->getTable();
     $query->from($table . ' as ' . ($hash = $this->getRelationCountHash()));
     $grammar = $query->getQuery()->getGrammar();
     $table = $grammar->wrapTable($table);
     $hash = $grammar->wrapTable($hash);
     $lft = $grammar->wrap($this->parent->getLftName());
     $rgt = $grammar->wrap($this->parent->getRgtName());
     return $query->whereRaw("{$hash}.{$lft} between {$table}.{$lft} + 1 and {$table}.{$rgt}");
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:19,代码来源:DescendantsRelation.php

示例14: scopeFilterByAdminGrid

 /**
  * @param Builder $query
  * @param         $filters
  * @param         $currentUserId
  */
 public function scopeFilterByAdminGrid(Builder $query, $filters, $currentUserId)
 {
     $query->select([User::getTableName() . '.*', 'up.*'])->join(Profile::getTableName() . ' AS up', 'up.user_id', '=', User::getTableName() . '.id', 'right');
     foreach ($filters as $filterKey => $filterValue) {
         if (empty($filterValue)) {
             continue;
         }
         switch ($filterKey) {
             case 'fname':
                 $query->where('fname', 'LIKE', '%' . $filterValue . '%');
                 break;
             case 'email':
                 $query->where('email', 'LIKE', '%' . $filterValue . '%');
                 break;
         }
     }
     $query->where('id', '!=', $currentUserId);
 }
开发者ID:middleout,项目名称:mdo-bundle-zf2-scaffold,代码行数:23,代码来源:User.php

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


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