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


PHP Builder::take方法代码示例

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


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

示例1: first

 /**
  * Execute the query and get the first result.
  *
  * @param  array   $columns
  *
  * @return mixed|static
  */
 public function first($columns = ['*'])
 {
     $this->query->take(1);
     $results = $this->get($columns);
     if ($results instanceof Collection) {
         return $results->first();
     }
     return count($results) > 0 ? reset($results) : null;
 }
开发者ID:viniijui,项目名称:codeTags,代码行数:16,代码来源:CacheDecorator.php

示例2: scopeQueryWithParams

 /**
  * A reusable query to pass params
  *
  * @param Builder $query
  * @param array $queryFilter
  *
  * @return Builder
  */
 public function scopeQueryWithParams($query, $queryFilter)
 {
     $limit = isset($queryFilter['limit']) ? $queryFilter['limit'] : 10;
     $perPage = isset($queryFilter['perPage']);
     $orderBy = isset($queryFilter['orderBy']) ? $queryFilter['orderBy'] : 'created_at';
     $sortOrder = isset($queryFilter['sortOrder']) ? $queryFilter['sortOrder'] : 'desc';
     $query->orderBy($orderBy, $sortOrder);
     if ($perPage) {
         return $query->paginate($perPage);
     }
     return $query->take($limit);
 }
开发者ID:lolzballs,项目名称:website,代码行数:20,代码来源:Post.php

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

示例4: take

 /**
  * Alias to set the "limit" value of the query.
  *
  * @param int $value
  * @return \Illuminate\Database\Query\Builder|static 
  * @static 
  */
 public static function take($value)
 {
     return \Illuminate\Database\Query\Builder::take($value);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例5: execute

 public function execute(Builder $query)
 {
     $query->take($this->getValue());
     return $query;
 }
开发者ID:brenodouglas,项目名称:QueryApi,代码行数:5,代码来源:Limit.php

示例6: getSome

 public function getSome($take, $skip = 0)
 {
     return $this->query->take($take)->skip($skip)->get();
 }
开发者ID:rekale,项目名称:sikasir,代码行数:4,代码来源:EloquentRepository.php

示例7: filterBySearchTerm

	/**
	 * Filters a relationship options query by a search term
	 *
	 * @param mixed										$term
	 * @param \Illuminate\Database\Query\Builder		$query
	 * @param array										$selectedItems
	 * @param \Frozennode\Administrator\Fields\Field	$fieldObject
	 * @param string									$relatedKeyTable
	 */
	public function filterBySearchTerm($term, QueryBuilder &$query, Field $fieldObject, array $selectedItems, $relatedKeyTable)
	{
		if ($term)
		{
			//set up the wheres
			foreach ($fieldObject->getOption('search_fields') as $search)
			{
				$query->where($this->db->raw($search), 'LIKE', '%'.$term.'%');
			}

			//exclude the currently-selected items if there are any
			if (count($selectedItems))
			{
				$query->whereNotIn($relatedKeyTable, $selectedItems);
			}

			//set up the limits
			$query->take($fieldObject->getOption('num_options') + count($selectedItems));
		}
	}
开发者ID:pcerbino,项目名称:falcionevega,代码行数:29,代码来源:Factory.php


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