first(); $rates = Rates::where('currency_id', $currency->id)->get(); foreach($rates as $rate) { $ret[] = ['x' => strtotime($rate->updated_at), 'y' => $rate->value]; } return $ret; }); Route::get('currency', function() { // If the Content-Type and Accept headers are set to 'application/json', // this will return a JSON structure. This will be cleaned up later. return Currency::all(); });