selectRaw("id, value, currency_id, relative_id, max(`created_at`) as created_at") ->groupByRaw('currency_id') ->get(); $rates = new Collection(); foreach($ratesRaw as $r) { $rate = Rates::find($r->id); if($rate->currency->name != "Bitcoin") { $rates->push($rate); } } return view('welcome', ['currencies' => Currency::all(), 'rates' => $rates]); });