'How to show monthly wise data in Laravel 8
I've posted about this three times and hopefully someone will help me with a solution. I have a lot of data in my database that the user has created.
Suppose I have 5 users report that they will create in January, when I click in January I see the data created by those 5 users. I've tried many queries but all monthly data is coming. I want to show the data by month. I'm brand new so I can't figure it out.
My database like below
column_one | month_name | user_id |
---|---|---|
3204234042 | January | user_1 |
4234234923 | February | user_2 |
5392342349 | January | user_3 |
7483234343 | February | user_4 |
I have tried with these queries.
$report = Report::status(1)->desk(15)->distric()->rentcertificate()->groupBy('month_name')->get();
$report = Report::select(DB::raw('column_one'),DB::raw("MONTHNAME(created_at) as monthname"))
->whereYear('created_at', date('Y'))
->groupBy('monthname')
->status(1)
->desk(15)
->distric()
->rentcertificate()
->get();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|