middleware('guest')->except('logout'); } public function index() { $data = [ //bawaan 'title' => $this->title, ]; return view('auth.login', $data); } public function action_login(Request $request) { $rule = [ 'email' => 'required|exists:users,email', 'password' => 'required' ]; $message = [ 'required' => 'The :attribute is required', 'exists' => ':attribute not found', ]; $validator = Validator::make($request->input(), $rule, $message); if ($validator->passes()) { $auth = Auth::attempt($request->only('email', 'password')); if ($auth) { // $request->session()->put('credential', Auth::user()); // return redirect(route('admin.dashboard')); if (empty(Auth::user()->rumah_sakit)) { // $data_history_logs = [ // 'type_id' => '1', // 'user_id' => Auth::user()->id, // 'log' => 'Login(SIDONI LAB)', // 'waktu' => Carbon::now()->format('Y-m-d H:i:s'), // 'ip_address' => Helper::get_ip_user(), // 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), // ]; // $insert_data_item_kantongs = HistoryLogs::insert($data_history_logs); $request->session()->put('credential', Auth::user()); return redirect(route('admin.dashboard')); } else { Auth::logout(); session()->flush(); session()->invalidate(); // return back()->with('error', 'Akun yang anda gunakan salah, Silahkan menggunakan Akun Rumah Sakit')->withInput(); return redirect(route('auth.index'))->with('message', Helper::failed_alert('Akun yang anda gunakan salah, Silahkan menggunakan Akun Admin'))->withInput(); } } else { return redirect(route('auth.index'))->with('message', Helper::failed_alert('Password Salah'))->withInput(); } } else { return redirect(route('auth.index'))->with('message', Helper::failed_alert('Email Belum Terdaftar'))->withInput();; } } }