3 months ago

Get count of rows in Laravel Eloquent before using paginate

Posted 3 months ago by timtom


I have a eloquent request with GroupBy and SelectRaw with joins table ... I would like to count the rows but when i do that i got the 'count' column in each row with the number of joined table rows ...

I think that i need to remove the 'selectRaw' and 'GroupBy' options from the query builder, but i would like to use the same query instance for the two requests.

I would like to do this but actualy it is not working :

$count = $query->count('settlements.id'); $data = $query->paginate($per_page, ['*'], 'page', $page);

Thanks for help

Please sign in or create an account to participate in this conversation.