How to get all entries created in a specific date range?
For some project I would like to display a stats page, displaying for example deposits for each single day.
Consider querying all the deposits at once and then using a group function to group by day. It will ease the load on your database to do it all in one query. Like this:
// get all the deposits for the last month
$all_deposits = Deposit::where('created_at','>',Carbon::now()->subMonth())->get();
// now group by the created date
$all_deposits->groupBy( function($deposit) {
return $deposit->created_at->format('Y-m-d');
});