src/Repositories/EloquentRepository.php
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,
        ];
    }
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,
        ];
    }
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 , ] ; }
Get all models sorted, filtered and paginated.

@param array $columns
@param array $with

@return array
Get all models sorted filtered and paginated .