toBase() public méthode

Get a base query builder instance.
public toBase ( ) : Builder
Résultat Illuminate\Database\Query\Builder
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * Get a base query builder instance.
  *
  * @return \Illuminate\Database\Query\Builder 
  * @static 
  */
 public static function toBase()
 {
     return \Illuminate\Database\Eloquent\Builder::toBase();
 }
Exemple #4
0
 /**
  * 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);
 }
Exemple #5
0
 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);
 }