i am new in laravel ,i trying to make custom validation from two table,
i have table users (contain id,email, password,job_type
) and another table name employee with fields user_id,admin_type_id
, my problem is when i trying to check data with login user and confirm he is an employee with job_tybe
=1 in table Employee and conform is type is admin by admin_type_id
=1 , when i make var_dump($admin)
i get output is null
i found my problem is password registers in data base not password that send from form how can i make password is i dental to make login condition of login is job_tybe
=1+ admin_type_id
=1 this is my code :-
public function authenticate(Request $request)
{
$credentials = array(
'email' => $request->get('email'),
'password' => $request->get('password'),
);
//check user is employee
$admin=User::where(['email' => $credentials['email'],'password' =>Hash::make($credentials['password']) ,'deleted'=>1,'status'=>1,'job_type'=>1])->first();
//get admin type
$adminType=Employee::where(['id_user' => $admin->id, 'admin_type_id'=>1,'deleted'=>1,'status'=>1])->first();;
if($adminType !=null)
{
if (Auth::attempt($credentials)) {
return redirect()->route('brand.create');
exit();
}
return redirect()->back()->with("messageError","Invalid Email Or Password");
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire