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


PHP Builder::addSelect方法代码示例

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


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

示例1: checkQuerySelects

 protected function checkQuerySelects()
 {
     $selects = $this->query->getQuery()->columns;
     $tableSelect = $this->model->getTable() . '.*';
     if (empty($selects) || !in_array($tableSelect, $selects)) {
         $this->query->addSelect($tableSelect);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:8,代码来源:RelationshipQueryJoiner.php

示例2: getQuery

 /**
  * Return the query.
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getQuery()
 {
     // If report is detailed, add all columns of modelGridQueries used by the gridQuery.
     // If report is summary, and method summaryGroupBy() is called, the columns are added
     // starting from the groupByKey which is a column of an modelGridQuery
     if ($this->isDetailed) {
         $this->query->addSelect($this->gridQuery->makeSelect($this->gridQuery->columnsToAddSelect()));
     }
     return $this->query;
 }
开发者ID:sedp-mis,项目名称:base-report,代码行数:15,代码来源:ReportQueryBuilder.php

示例3: select

 /**
  * @param Builder $query
  *
  * @return void
  */
 public function select(Builder $query)
 {
     if (!is_null($select = $this->getRule()->getField()->getSelectField())) {
         if ($select instanceof Builder) {
             $query->selectSub($select->toSql(), $this->getRule()->getField()->getQueryField());
         } else {
             $query->addSelect($select);
         }
     }
 }
开发者ID:KodiComponents,项目名称:module-datasource,代码行数:15,代码来源:Operator.php

示例4: filter

 /**
  * Filter a query by the value of a
  * field using this field type.
  *
  * @param Builder         $query
  * @param FilterInterface $filter
  */
 public function filter(Builder $query, FilterInterface $filter)
 {
     $stream = $filter->getStream();
     $assignment = $stream->getAssignment($filter->getField());
     $column = $this->fieldType->getColumnName();
     $translations = $stream->getEntryTranslationsTableName();
     if ($assignment->isTranslatable()) {
         if ($query instanceof EloquentQueryBuilder && !$query->hasJoin($translations)) {
             $query->leftJoin($stream->getEntryTranslationsTableName(), $stream->getEntryTableName() . '.id', '=', $stream->getEntryTranslationsTableName() . '.entry_id');
         }
         $query->addSelect($translations . '.locale');
         $query->addSelect($translations . '.' . $column);
         $query->{$this->where()}(function (Builder $query) use($stream, $filter, $column) {
             $query->where($stream->getEntryTranslationsTableName() . '.locale', config('app.locale'));
             $query->where($stream->getEntryTranslationsTableName() . '.' . $column, 'LIKE', "%" . $filter->getValue() . "%");
         });
     } else {
         $query->{$this->where()}(function (Builder $query) use($stream, $filter, $column) {
             $query->where($stream->getEntryTableName() . '.' . $column, 'LIKE', "%" . $filter->getValue() . "%");
         });
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:29,代码来源:FieldTypeQuery.php

示例5: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     if (isset($model['calculated_columns'])) {
         $builder->addSelect('*');
         foreach ($model['calculated_columns'] as $column => $query) {
             if (str_contains($query, ':user_id')) {
                 $query = auth() && auth()->user() ? str_replace(':user_id', auth()->user()->id, $query) : 'false';
             }
             $builder->selectSub($query, $column);
         }
     }
     return $builder;
 }
开发者ID:snetty,项目名称:laravel-calculated-columns,代码行数:20,代码来源:CalculatedColumnsScope.php

示例6: filterScopes

 /**
  * Очень простая фильтрация скоупов.
  *
  * Если необходимо отфильтровать скоупы по id чему либо, обязательно нужно создать scope следующего вида.<br>
  * Пример:
  * * Ссылка для фильтрации - `catalog_id=*`
  * * Метод - `public function scopeCatalogId($int) {}`
  *
  * @return \Illuminate\Support\Collection
  */
 protected function filterScopes()
 {
     if (count($this->_request) > 0) {
         foreach ($this->_request as $scope => $value) {
             if (!empty($value)) {
                 //checked scope method for model
                 if (method_exists($this->_query->getModel(), 'scope' . camel_case($scope))) {
                     $this->_query->{camel_case($scope)}($value);
                 } else {
                     $values = explode(',', $value);
                     if (count($values) > 1) {
                         $this->filterSearch($scope, $values[0], '>');
                         $this->filterSearch($scope, $values[1], '<');
                     } else {
                         $this->filterSearch($scope, $value, 'like', '%', '%');
                     }
                 }
             }
         }
         $this->_query->addSelect($this->_query->getModel()->getTable() . '.*');
     }
     return $this->_request;
 }
开发者ID:assurrussa,项目名称:grid-view-vue,代码行数:33,代码来源:GridView.php

示例7: execute

 public function execute(Builder $query)
 {
     return $query->addSelect(DB::raw("(((match(search_texts.title) against ('{$this->text}')) * 100) + ((match(search_texts.meta) against ('{$this->text}')) * 20) + ((match(search_texts.standfirst) against ('{$this->text}')) * 10) + match(search_texts.text) against ('{$this->text}')) as rel"))->join('search_texts', 'pages.id', '=', 'search_texts.page_id')->where('search_texts.embargoed_until', '<=', time())->orderBy('rel', 'desc');
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:4,代码来源:Search.php

示例8: addSelectsToQuery

 /**
  * Puts all the select clauses to the main query.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param array $selects
  */
 protected function addSelectsToQuery(Builder $query, array $selects)
 {
     $selects = new Expression(implode(' + ', $selects) . ' as relevance');
     $query->addSelect($selects);
 }
开发者ID:singgihsap,项目名称:elearning,代码行数:11,代码来源:SearchableTrait.php

示例9: querySelectColumn

 /**
  * @param Builder           $query
  * @param DocumentInterface $document
  */
 public function querySelectColumn(Builder $query, DocumentInterface $document)
 {
     $query->addSelect($this->getDBKey());
 }
开发者ID:KodiComponents,项目名称:module-datasource,代码行数:8,代码来源:Field.php

示例10: apply

 /**
  * @param Builder $table
  *
  * @return Builder
  */
 public function apply(Builder $table)
 {
     return $table->addSelect($this->getColumnsToSelect());
 }
开发者ID:middleout,项目名称:doplio,代码行数:9,代码来源:SelectOnlyCertainColumns.php

示例11: build

 public function build(Builder $query)
 {
     return $query->addSelect(DB::raw('count(pages_tags.tag_id) as tag_count'))->join('pages_tags', 'pages.id', '=', 'pages_tags.page_id')->whereIn('tag_id', $this->tagIds)->where('pages.id', '!=', $this->page->getId())->orderBy('tag_count', 'desc')->orderBy(DB::raw('rand()'))->groupBy('pages.id');
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:4,代码来源:RelatedByTags.php


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