has('f')) { $data = $request->validate(['f' => 'regex:/[df]/']); $request->session()->put('filter', $data['f']); } if ($request->has('fclt')) { $data = $request->validate(['fclt' => 'integer|exists:faculties,id']); $request->session()->put('faculty', $data['fclt']); } if ($request->has('dept')) { $data = $request->validate(['dept' => 'integer|exists:departments,id']); $request->session()->put('department', $data['dept']); } if (!$request->session()->has('filter')) { $request->session()->put('filter', 'd'); } if (!$request->session()->has('department')) { $default_dept_id = \App\Department::where('name', '=', 'BIOL')->first()->id; $request->session()->put('department', $default_dept_id); } // dump($request->session()); return $next($request); } }