public function index()
    {
        $options = $this->getQueryHelperOptions();
        $items = $this->repo->allPaged($options);

        if ( ! $items)
        {
            return $this->respondNotFound('Unable to fetch the selected resources');
        }

        $response = [
            'data' => [],
            'meta' => [
                'pagination' => []
            ]
        ];

        $resource = new Fractal\Resource\Collection($items->getCollection(), new $this->transformerClass);
        $resource->setPaginator(new Fractal\Pagination\IlluminatePaginatorAdapter($items));

        $response['data'] = $this->fractal->createData($resource)->toArray()['data'];

        $paginator = new Fractal\Pagination\IlluminatePaginatorAdapter($items);

        $response['meta']['pagination'] = [
            'total' => $paginator->getTotal(),
            'count' => $paginator->count(),
            'per_page' => $paginator->getPerPage(),
            'current_page' => $paginator->getCurrentPage(),
            'total_pages' => $paginator->getLastPage()
        ];

        return $response;
    }
public function index()
    {
        $options = $this->getQueryHelperOptions();
        $items = $this->repo->allPaged($options);

        if ( ! $items)
        {
            return $this->respondNotFound('Unable to fetch the selected resources');
        }

        $response = [
            'data' => [],
            'meta' => [
                'pagination' => []
            ]
        ];

        $resource = new Fractal\Resource\Collection($items->getCollection(), new $this->transformerClass);
        $resource->setPaginator(new Fractal\Pagination\IlluminatePaginatorAdapter($items));

        $response['data'] = $this->fractal->createData($resource)->toArray()['data'];

        $paginator = new Fractal\Pagination\IlluminatePaginatorAdapter($items);

        $response['meta']['pagination'] = [
            'total' => $paginator->getTotal(),
            'count' => $paginator->count(),
            'per_page' => $paginator->getPerPage(),
            'current_page' => $paginator->getCurrentPage(),
            'total_pages' => $paginator->getLastPage()
        ];

        return $response;
    }
public function index ( ) { $ options = $ this -> getQueryHelperOptions ( ) ; $ items = $ this -> repo -> allPaged ( $ options ) ; if ( ! $ items ) { return $ this -> respondNotFound ( 'Unable to fetch the selected resources' ) ; } $ response = [ 'data' => [ ] , 'meta' => [ 'pagination' => [ ] ] ] ; $ resource = new Fractal \ Resource \ Collection ( $ items -> getCollection ( ) , new $ this -> transformerClass ) ; $ resource -> setPaginator ( new Fractal \ Pagination \ IlluminatePaginatorAdapter ( $ items ) ) ; $ response [ 'data' ] = $ this -> fractal -> createData ( $ resource ) -> toArray ( ) [ 'data' ] ; $ paginator = new Fractal \ Pagination \ IlluminatePaginatorAdapter ( $ items ) ; $ response [ 'meta' ] [ 'pagination' ] = [ 'total' => $ paginator -> getTotal ( ) , 'count' => $ paginator -> count ( ) , 'per_page' => $ paginator -> getPerPage ( ) , 'current_page' => $ paginator -> getCurrentPage ( ) , 'total_pages' => $ paginator -> getLastPage ( ) ] ; return $ response ; }
Return items in a paged way

@return mixed
Return items in a paged way