score:0

In your model;

use this

public function getCreatedAtAttribute($value)
{
    return  date('m/d/Y', strtotime($value));
}

score:1

Turns out, it was the 'dates' variable causing the problem (in addition to a syntax error). Chartjs was looking for an array like: ["2015/06/08", 2015/06/13", "2015/6/20"] instead of the collection object from the eloquent query. So I ran $dates = array_column($inventories->toArray(), 'updated_at'); to get the array, then reformatted the dates by running:

foreach ($dates as $date){
    $formatted_dates[] = date('m/d/Y', strtotime($date));
}

Then I passed $formatted_dates to the view. I'm sure there's a better way, but I'm learning more everyday and it works for me!


Related Query

More Query from same tag