/** * Show the application dashboard. * * @return \Symfony\Component\HttpFoundation\Response */ public function index() { $user = Auth::user(); $events = collect(); if ($user->personalDetails && $user->personalDetails->events) { $ids = $user->personalDetails->events->pluck('id'); $events = Event::whereNotIn('id', $ids)->active()->latest()->limit(5)->get(); } elseif (!$user->personalDetails || !$user->personalDetails->events) { $events = Event::active()->latest()->limit(5)->get(); } $activeEvents = Event::active()->latest()->limit(5)->get(); return view('home', compact('events', 'user', 'activeEvents')); }