Teranode's avatar

[L5] Pagination Issues Presented

I'm having a little problem converting the cacheTags to suit L5's Standards. Originally this was what I was using to pass pagination into the cache:

    /**
     * Builds paginate query with given parameters.
     * 
     * @param  array   $params
     * @param  integer $page
     * @param  integer $perPage
     * 
     * @return array
     */
    public function buildPaginateQuery(array $params, $page = 1, $perPage = 15)
    {
        $query = $this->model->table == 'links' ? $this->model->with('Title') : $this->model;

        $query = $this->appendParams($params, $query);

        $count = $query->cacheTags('count')->remember(2000)->count();

        $totalPages = $count / $perPage;
    
        $query = $query->skip($perPage * ($page - 1))->take($perPage);

        $query = $query->order(isset($params['order']) && $params['order'] ? $params['order'] : null);

        $query = $query->cacheTags(array($this->model->table, 'pagination'))->remember(2000);
        
        return array('query' => $query, 'totalPages' => $totalPages, 'totalItems' => $count);
    }

This however doe not work since L5 removed cacheTags support. I have tried to fix it myself but it doesn't work. Does anyone know the equivalent of what this would look like in L5?

0 likes
2 replies
Teranode's avatar

_> fixed it myself after going through 3 days of no solution in multiple places, thx everyone....

bobbybouwmann's avatar

Can you share your solution for other users? Would be cool to see your solution

Please or to participate in this conversation.