middleware('auth'); } public function index(Request $request, $component = null) { $view = $component ? "dashboard.{$component}" : 'dashboard.default'; if (!view()->exists($view)) { return redirect()->route('login')->with('error', 'You must log in to enter this page'); } return view('dashboard.route', compact('view')); } }