I have same number of rows with groupBy as well without it.
$authors = AuthorMask::where('company_id', $user->company_id)
->groupBy('id', 'author_id')
->orderBy('created_at', 'desc')
->paginate(5);
If I use this:
$authors = AuthorMask::where('company_id', $user->company_id)
->groupBy('author_id')
->orderBy('created_at', 'desc')
->paginate(5);
I get an error.
SQLSTATE[42803]: Grouping error: 7 ERROR: column "author_masks.id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select * from "author_masks" where "company_id" = $1 group b... ^ (SQL: select * from "author_masks" where "company_id" = 1 group by "author_id" order by "created_at" desc limit 5 offset 0)