So if im having a notices
table
where i store title, body and date
.
Now i want to display it in the below format
2018-01-09
Title Body
abc abc123
pqr pqr123
2018-01-10
Title Body
mno mno123
pqr pqr123
So I have input for start date
and end date
which gets all notices between those dates.
$notices = App\Notice::whereBetween('date', [$request->start_date, $request->end_date])->oldest('date')->get();
But now i dont know how to filter data by date and print one group of notices ex. 2018-01-09
first and then another group of notices ex. 2018-01-10
and so on.
How to achieve this ?
Use Collection::groupBy method to group data by date field: