62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Models\StudentPortalLog ;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
|
|
class StudentPortalController extends Controller
|
|
{
|
|
public function studentlogin(Request $request)
|
|
{
|
|
$request->validate([
|
|
'username' => 'required',
|
|
'password' => 'required',
|
|
'pin' => 'required|numeric',
|
|
]);
|
|
|
|
$student = DB::table('student_portal_logs')
|
|
->where('email', $request->username)
|
|
->first();
|
|
|
|
if ($student && Hash::check($request->password, $student->password) && $student->pin == $request->pin) {
|
|
if ($student->status !== 'active' && $student->status !== '') {
|
|
return redirect('/')->with('error', 'Your account is inactive!');
|
|
}
|
|
$request->session()->put('student_id', $student->studentid);
|
|
return redirect()->route('student.portal')->with('success', 'Logged in successfully!');
|
|
}
|
|
return redirect('/')->with('error', 'Invalid Email, Password, or PIN!');
|
|
}
|
|
|
|
|
|
// public function showProfile(Request $request)
|
|
// {
|
|
|
|
// $log_id = $request->session()->get('student_id');
|
|
|
|
|
|
// if (!$log_id) {
|
|
// return redirect('/')->with('error', 'Please login first!');
|
|
// }
|
|
|
|
|
|
// $student = DB::table('student_details')
|
|
// ->where('student_portal_log_id', $log_id)
|
|
// ->first();
|
|
|
|
|
|
// if (!$student) {
|
|
// return redirect()->back()->with('error', 'Student details not found!');
|
|
// }
|
|
|
|
|
|
// return view('StudentProfile', compact('student'));
|
|
// }
|
|
|
|
}
|