BigSpender's avatar

Override getCountForPagination method

Good morning.

I'd like to override in Laravel 8.x this method. Does anyone can give advise how we can do it in the good tradition on application level? Please do not suggest me to use patches. I looking for some way like plugins and preferences in magento 2. Thanks!

public function getCountForPagination($columns = ['*'])
    {
        $results = $this->runPaginationCountQuery($columns);

        // Once we have run the pagination count query, we will get the resulting count and
        // take into account what type of query it was. When there is a group by we will
        // just return the count of the entire results set since that will be correct.
        if (! isset($results[0])) {
            return 0;
        } elseif (is_object($results[0])) {
            return (int) $results[0]->aggregate;
        }

        return (int) array_change_key_case((array) $results[0])['aggregate'];
    }
0 likes
3 replies
tykus's avatar

Why exactly are you needing to override a Builder method?

BigSpender's avatar

For instance in some cases I'd like to take count for pagination from cache

Please or to participate in this conversation.