Answer the question
In order to leave comments, you need to log in
How to correctly implement a request in Laravel?
Good day everyone!
There is a Report model, you need to get the data so that they are sorted (or grouped) by month, the sorting field is `created_at` type timestamp.
I will try to explain the task itself in a little more detail, there is a site.ru/report/january route, when you go, a list of models added in January opens.
Using sql, this can be done using MONTH ORDER BY MONTH(created_at) ASC
How to implement this using Laravel Eloquent ORM?
Answer the question
In order to leave comments, you need to log in
Report::orderByRaw('MONTH(created_at) ASC')->get()
Report::whereRaw("'MONTH(created_at) = 1")->orderBy('created_at')->get()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question