I wish to sum up payment_amount by created_at date and assign the total by month to two different variables so I can plot on charts js x and y axis.
So far i have output json string using the below code.
public function index()
{
$data = [
'period' => Payment::all('created_at', 'payment_amount')->groupBy(function($date) {
return Carbon::parse($date->created_at)->format('F');
})->tojson(),
];
//dd($data);
return view('admin.dashboard', $data);
}
so to one json string I wish to have $created_at //which goes on the x axis $total payment_amount //which goes on y axis.
via Eden WebStudio