middleware('guest')->except('logout'); $this->middleware('auth')->only('logout'); } public function authenticate(Request $request) { // dd('The custom method is running!'); $request->validate([ 'email' => 'required|email', 'password' => 'required', ]); $staff = StaffMember::where('email', $request->email)->where('status', 'ACTIVE')->first(); // 1. Check if staff exists and password is correct if ($staff && Hash::check($request->password, $staff->password)) { // 2. Generate 6-digit OTP $otp = rand(100000, 999999); $staff->update([ 'otp_code' => $otp, 'otp_expires_at' => now()->addMinutes(3) ]); \Log::info($otp); Mail::to($staff->email)->send(new LoginOtpMail($otp)); session(['otp_staff_id' => $staff->id]); return redirect()->route('otp.verify'); } return back()->withErrors(['email' => 'Invalid credentials or inactive account.']); } }