How can I make this query in Eloquent?
select count(id) as NumeroPreguntas, user_id
from preguntas
group by user_id
order by NumeroPreguntas
DESC Limit 10;
I tried
pregunta::groupBy('categoria_id')->get()
but it does not work, but if I disable the Strcit mode of laravel database, then it works but I do not want to do that.
if I do this
$res = Pregunta::where('user_id',2)->take(10)->get();
$res = $res->GroupBy('categoria_id')
So if it works, but the problem is that I need to only take out the users that have asked the most questions. I just want to take the first 10
And I do not know how to do so that I take 10 with more questions. Since the above sql code does work but in Eloquent I do not know how.