user() != null && auth()->user()->fireStationID != null ){ $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get(); $decoration = DB::table('decorations')->pluck('decorationName', 'id'); return view("documentApplicationForm") ->with(compact('decoration')) ->with(compact('fireFighters')); } else{ return view('home'); } } public function printPDF(){ if(auth()->user() != null && auth()->user()->fireStationID != null ) { $request = request(); $test = new documentOverlayController(); $userData = DB::table('users')->where("users.id", '=', $request->fireFighterID) ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') ->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.fireStationID','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number') ->first(); $fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first(); $test->testPdf($userData, $request->decoration, $fireStation); } } }