public function paginate(Query $query, $page = 1, $limit = 10, $fetchJoinCollection = false): array
    {
        $paginator = new Paginator($query, $fetchJoinCollection);
        $totalItems = $paginator->count();
        $pagesCount = ceil($totalItems / $limit);
        $paginator
            ->getQuery()
            ->setFirstResult($limit * ($page - 1))// offset
            ->setMaxResults($limit); // limit

        return [
            'meta' => [
                'page' => $page,
                'total' => $totalItems,
                'pages' => $pagesCount,
                'limit' => $limit,
            ],
            'data' => $paginator
        ];
    }
public function paginate(Query $query, $page = 1, $limit = 10, $fetchJoinCollection = false): array
    {
        $paginator = new Paginator($query, $fetchJoinCollection);
        $totalItems = $paginator->count();
        $pagesCount = ceil($totalItems / $limit);
        $paginator
            ->getQuery()
            ->setFirstResult($limit * ($page - 1))// offset
            ->setMaxResults($limit); // limit

        return [
            'meta' => [
                'page' => $page,
                'total' => $totalItems,
                'pages' => $pagesCount,
                'limit' => $limit,
            ],
            'data' => $paginator
        ];
    }
public function paginate ( Query $ query , $ page = 1 , $ limit = 10 , $ fetchJoinCollection = false ) : array { $ paginator = new Paginator ( $ query , $ fetchJoinCollection ) ; $ totalItems = $ paginator -> count ( ) ; $ pagesCount = ceil ( $ totalItems / $ limit ) ; $ paginator -> getQuery ( ) -> setFirstResult ( $ limit * ( $ page - 1 ) ) // offset -> setMaxResults ( $ limit ) ; // limit return [ 'meta' => [ 'page' => $ page , 'total' => $ totalItems , 'pages' => $ pagesCount , 'limit' => $ limit , ] , 'data' => $ paginator ] ; }
Paginates a query

@param Query $query
@param int $page
@param int $limit
@param bool $fetchJoinCollection
@return array
Paginates a query