I am returning JSON from this array, but the value of total
is in string format - not a float. Not sure what I am doing wrong here.
This is the array, which ends up having a string:
return [
'cart' => [
'total' => amount($cart->total)
]
]
And this is the amount
helper method, where the issue is coming from:
function amount($money)
{
return number_format(floatval($money), 2);
}
I am expecting a float back from total
, not a string.