validate([ 'username' => 'required', 'password' => 'required', 'pin' => 'required|numeric', ]); $student = DB::table('student_portal_logs') ->where('email', $request->username) ->first(); // 1. Hash::check පාවිච්චි කරලා password එක check කරන්න if ($student && Hash::check($request->password, $student->password) && $student->pin == $request->pin) { // 2. Status එක active හෝ හිස් ("") වුණොත් ඇතුලට යන්න දෙන්න if ($student->status !== 'active' && $student->status !== '') { return redirect('/')->with('error', 'Your account is inactive!'); } // Session එකට ID එක දානවා $request->session()->put('student_id', $student->studentid); // කෙලින්ම Student Portal එකට redirect කරනවා return redirect()->route('student.portal')->with('success', 'Logged in successfully!'); } // දත්ත වැරදියි නම් හෝම් පේජ් එකට යවනවා return redirect('/')->with('error', 'Invalid Email, Password, or PIN!'); } }