I´ve seen similiar questions but honestly i didn´t see anything that could take me to the right way and that´s because i´m also looking for a better way of doing this.
At certain point in my app i´m using chartjs, where i need to show months and then the values(sales). For that i know(or i think) i have to retrieve data group by months, and i got here so far:
$records = TabelaAngariacao::select('preco', 'created_at')->where('estado', '=', 'Vendido')
->get()
->groupBy(function($date) {
return Carbon::parse($date->created_at)->format('m');
});
Well...as you can see, i´m not SUMING anything, and that´s because in my database my values are getting stored in varchar(with dot´s!) and i know that´s not the proper way of doing things, but at this point changing everything it´s not a solution for me right now, so how could i change that function in order to remove the dot´s and do a proper sum? i have tried using CAST but it´s giving me undefinied function.
Any suggestions? Thanks for your time, regards.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire