public function dashboard() { $today = Carbon::today('Europe/Brussels'); $now = Carbon::now('Europe/Brussels'); $clients = Client::where('leavetime', '=', null)->get(); $clientsWithTable = collect([]); foreach ($clients as $client) { if ($client->table != null) { $clientsWithTable->push($client); } } foreach ($clientsWithTable as $client) { if (count($client->orders) > 0) { $order = $client->orders()->where('endtime', '=', null)->first(); if ($order) { $client->wait_time = $now->diffInMinutes(Carbon::createFromFormat('Y-m-d H:i:s', $order->starttime)); } } } $areas = ['' => 'Gebieden'] + Area::orderby('name', 'ASC')->lists('name', 'id')->all(); $locations = Location::with('table')->with('decoration')->get(); return View::make('dashboard')->with('today', $today)->with('clientsWithTable', $clientsWithTable)->with('areas', $areas)->with('locations', $locations); }