Get all models sorted, filtered and paginated.

@param array $columns
@param array $with

@return array
340797
public function allFiltered($columns = [], array $with = [])
    {
        $params = request()->all();
        $data = $this->with($with)->select($columns);

        $orderBy = $params['orderBy'] ?? null;
        $query = $params['query'] ?? null;
        $limit = $params['limit'] ?? null;
        $page = $params['page'] ?? 1;
        $ascending = $params['ascending'] ?? 1;
        $byColumn = $params['byColumn'] ?? 0;

        if ($query !== null) {
            $data = $byColumn == 1 ? $this->filterByColumn($data, $query) :
                                     $this->filter($data, $query, $columns);
        }

        $count = $data->count();

        if ($limit !== null) {
            $data->limit($limit)->skip($limit * ($page - 1));
        }
        if ($orderBy !== null) {
            $orderBy .= $this->translatableOperator($orderBy);
            $direction = $ascending == 1 ? 'ASC' : 'DESC';
            $data->orderBy($orderBy, $direction);
        }

        $results = $data->get()
            ->translate(config('typicms.content_locale'));

        return [
            'data' => $results,
            'count' => $count,
        ];
    }
875603
public function withColumns(array $columns): self
    {
        $loader = clone $this;
        $loader->columns = array_merge(
            [$loader->schema[Record::SH_PRIMARY_KEY]],
            $columns
        );

        return $loader;
    }
158035
public function get($columns = ['*'])
    {
        if ($this->query->from instanceof Subquery) {
            $this->wheresToSubquery($this->query->from);
        }

        return parent::get($columns);
    }
937597
public function getModels($columns = array('*'))
    {
        // make sure that we select the version table, if the main table is selected
        $tempColumns = isset($this->query->columns)
            ? array_merge($columns, $this->query->columns)
            : $columns;
        foreach($tempColumns as $column) {
            $segments = explode('.', $column);
            if ($segments[0] == $this->model->getTable()) {
                $this->query->addSelect($this->model->getVersionTable().'.*');
                break;
            }
        }

        return parent::getModels($columns);
    }
381168
public function findWith($find, array $with = [], $column = 'id', array $columns = ['*'])
    {
        return $this->whereWith($find, $column, $with)->firstOrFail($columns);
    }
615495
public function findWhere(array $wheres, array $columns = ['*'])
    {
        return $this->mediator->transform($this->mediator(func_get_args()))->first();
    }
1005923
public function getModels($columns = ['*'])
    {
        return $this->model->hydrate(
            $this->query->get($columns)->all(),
            $this->model->getConnectionName()
        )->all();
    }
375009
protected function joinClosureBy($column, $withSelf = false)
    {
        $primary = $this->getQualifiedKeyName();
        $closure = $this->closure->getTable();
        $ancestor = $this->closure->getQualifiedAncestorColumn();
        $descendant = $this->closure->getQualifiedDescendantColumn();

        switch ($column) {
            case 'ancestor':
                $query = $this->join($closure, $ancestor, '=', $primary)
                    ->where($descendant, '=', $this->getKey());
                break;

            case 'descendant':
                $query = $this->join($closure, $descendant, '=', $primary)
                    ->where($ancestor, '=', $this->getKey());
                break;
        }

        $depthOperator = ($withSelf === true ? '>=' : '>');

        $query->where($this->closure->getQualifiedDepthColumn(), $depthOperator, 0);

        return $query;
    }
1145857
public function setSortableColumns($columns)
    {
        if (!empty($this->columns()->sortable)) {
            $columns = array_merge($columns, $this->columns()->sortable);
        }

        return $columns;
    }
1191906
public function get($columns = ['*'])
    {
        $columns = $this->query->getQuery()->columns ? [] : $columns;

        if ($columns === ['*']) {
            $columns = [$this->related->getTable().'.*'];
        }

        $columns[] = $this->getQualifiedFirstLocalKeyName().' as '.static::THROUGH_KEY;

        $this->query->addSelect($columns);

        return $this->query->get();
    }
972373
public function findWhere($where, $columns = ['*'], $or = false)
    {
        $model = $this->query();

        foreach ($where as $field => $value) {

            if ($value instanceof Closure) {

                $model = ( ! $or)
                    ? $model->where($value)
                    : $model->orWhere($value);

            } elseif (is_array($value)) {

                if (count($value) === 3) {

                    list($field, $operator, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $operator, $search)
                        : $model->orWhere($field, $operator, $search);

                } elseif (count($value) === 2) {

                    list($field, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $search)
                        : $model->orWhere($field, $search);
                }

            } else {
                $model = ( ! $or)
                    ? $model->where($field, $value)
                    : $model->orWhere($field, $value);
            }
        }

        return $model->get($columns);
    }
759864
public function withColumns(array $columns): self
    {
        $selector = clone $this;
        $selector->loader = $selector->loader->withColumns($columns);

        return $selector;
    }
942253
protected function getSelectedWithColumns()
    {
        $result = [];
        foreach ($this->withFields as $fieldSourceAlias => $withInfo) {
            list ($collection, $fields) = $withInfo;
            $resolvedFields = $this->resolveSelectiveFields($collection, $fields, []);
            $result = array_merge($result, $this->getSelectedColumns($resolvedFields, $fieldSourceAlias));
        }

        return $result;
    }
1083100
public function makeAdminColumnsSortable($columns)
    {
        $admin_columns = $this->getAdminColumns();
        if (!Arr::iterable($admin_columns)) {
            return $columns;
        }

        foreach ($admin_columns as $k) {
            $columns[$k] = $k;
        }
        return $columns;
    }
99415
public function manage_posts_columns( $columns, $sortable = false ) {
		if ( ! $sortable ) {
			$title = $this->get_post_column_title();
			! isset( $title ) and isset( $columns['title'] ) and $title = $columns['title'];
			$date = isset( $columns['date'] ) ? $columns['date'] : null;
			unset( $columns['date'] );
		}

		$columns = $this->pre_filter_posts_columns( $columns, $sortable );
		$columns = $this->post_filter_posts_columns( $columns, $sortable );

		if ( ! $sortable ) {
			isset( $title ) and $columns['title'] = $title;
			isset( $date ) and $columns['date'] = $date;
		}

		return $columns;
	}
290081
public function selectModelColumns(iterable $columns = null): self
    {
        if ($columns !== null) {
            $quotedColumns = [];
            foreach ($columns as $column) {
                $quotedColumns[] = $this->quoteDoubleIdentifier($this->getAlias(), $column);
            }
        } else {
            $quotedColumns = $this->getModelColumns();
        }

        $this->select($quotedColumns);

        return $this;
    }
401639
public function orWhereMultiple(array $columns)
    {
        $instance = $this->whereStrategyInstance();

        $instance->whereStrategy()->orWhereMultiple($columns);

        return $instance;
    }