I have a table with the following fields:
id, texto, autor_id, data
I need the records to be grouped by autor_id
(because it has multiple texts with the same author) and I get the newest ones in ascending order only. I'm using Lavarel and my Eloquent code looks like this:
Discursos::take(10)->distinct('membro_id')->orderBy('data_discurso', 'asc')->get();
If I put groupBy
instead of distinct
, I'm returning only the oldest of the records. How to do it the other way around?
What I'm doing is returning a list of text in which the author has not registered for some time, I want you to return to me to know which author does not register anything.