本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::toBase方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::toBase方法的具体用法?PHP Builder::toBase怎么用?PHP Builder::toBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::toBase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* Initialize
*
* @return void
*/
public function initialize()
{
if (!$this->initialized) {
$query = $this->builder->toBase();
$sql = $query->toSql();
$bindings = $query->getBindings();
$conn = $query->getConnection();
$this->statement = $conn->getPdo()->prepare($sql);
$this->statement->execute($conn->prepareBindings($bindings));
$this->prototype = $this->builder->getModel()->newFromBuilder();
}
$this->initialized = true;
}
示例2: paginate
/**
* Paginate the returned set of models.
*
* @param int $perPage
* @param array $columns
* @param string $pageName
* @param int|null $page
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*
* @throws \InvalidArgumentException
*/
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$query = $this->model->toBase();
$total = $query->getCountForPagination();
$model = $this->model->forPage($page = $page ?: Paginator::resolveCurrentPage($pageName), $perPage = $perPage ?: $this->model->getPerPage());
$results = new LengthAwarePaginator($this->hookPaginate($model->get($columns)), $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName]);
$this->reset();
return $results;
}
示例3: toBase
/**
* Get a base query builder instance.
*
* @return \Illuminate\Database\Query\Builder
* @static
*/
public static function toBase()
{
return \Illuminate\Database\Eloquent\Builder::toBase();
}
示例4: addHasWhere
/**
* Add the "has" condition where clause to the query.
*
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param string $operator
* @param int $count
* @param string $boolean
* @return \Illuminate\Database\Eloquent\Builder|static
*/
protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator, $count, $boolean)
{
$hasQuery->mergeModelDefinedRelationConstraints($relation->getQuery());
if ($this->shouldRunExistsQuery($operator, $count)) {
$not = $operator === '<' && $count === 1;
return $this->addWhereExistsQuery($hasQuery->toBase(), $boolean, $not);
}
return $this->whereCountQuery($hasQuery->toBase(), $operator, $count, $boolean);
}
示例5: parsePagination
protected function parsePagination(array $params, Query $query)
{
$page = isset($params['page']) ? $params['page'] : 1;
$this->maxPages = (int) ceil($query->toBase()->getCountForPagination() / self::UNITS_PER_PAGE);
return $query->forPage($page, self::UNITS_PER_PAGE);
}