如何使用此queryBuilder检查laravel中的用户是否存在? 问题是检查密码:
$user = DB::table('users')
->where('email',$request->input('email'))
->where('password',bcrypt($request->input('password')))
->first();
答案 0 :(得分:2)
auth()->attempt(['email' => $request->email, 'password' => $request->password])
如果您只想检查密码,请使用Hash::check()
:
Hash::check($request->password, $passwordFromDb)
答案 1 :(得分:2)
收到电子邮件
$user = DB::table('users')
->where('email',$request->input('email'))
->first();
检查密码
use Illuminate\Support\Facades\Hash;
if(Hash::check($user->password,Hash::make($request->input('password')))){ echo"Password current"; }else{ echo "Password Wrong";}