can someone help me please.. i have database with activities members and want to display in chartjs last 7 days data.
id member_id bonus created_at
1 1 3 2020-04-16
2 1 3 2020-04-17
3 1 7 2020-04-18
4 1 5 2020-04-19
5 1 15 2020-04-20
6 1 10 2020-04-21
7 1 9 2020-04-22
8 1 11 2020-04-24
my laravel code
$chart = charts::where('member_id', Auth::user()->id)->orderBy('id', 'asc')->where('created_at', '>=', \Carbon\Carbon::today()->subDays(7))->get();
$bonus = [];
foreach ($charts as $index => $count) {
$bonus[] = [$count->bonus];
}
return view('index', ['bonus' => $bonus]);
problem is in chart because display data from 2020-04-17 to 2020-04-24 and it's logic, but i want to show also in chart days when member don't have any bonus for example 2020-04-23 not exists because member didn't have bonus this day, so i need to show in chart 0 in 2020-04-23.
can someone help me ?