I am working with laravel 5.2 and i want to login the user if the status is active
Route::get('/ProductInquiry', function(){
$id = session('esysid');
$user = UsersModel::where('employeeID', 'LIKE', $id)->get();
session(['name' => $user[0]->sAMAccountName]);
return view('home');
})->name('home');
I have status column in my database and I need help to authenticate the active users by getting the user's status here in routes, so I can know who are the active users of the system. I expect to login the users which have a status = 1.
You can use Laravel Where
Clause the achieve your result
Route::get('/ProductInquiry', function(){
$id = session('esysid');
$userDetail = UsersModel::where('employeeID', $id)->where('status', 1)->first();
session(['name' => $userDetail->sAMAccountName]);
return view('home');
})->name('home');
Also, As the employeeID is unique so you can use first
in place of get
method.
get() - Return a collection.
first() - Return a single object.