has('f')) { $data = $request->validate(['filter' => 'regex:/[df]/']); $request->session()->put('filter', $data['filter']); } if ($request->has('fclt')) { $data = $request->validate(['setfclt' => 'integer|exists:faculties,id']); $request->session()->put('faculty', $data['setfclt']); } if ($request->has('dept')) { $data = $request->validate(['setdept' => 'integer|exists:departments,id']); $request->session()->put('department', $data['setdept']); } 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); } return $next($request); } }