Laravel Checking If a Record Exists

后端 未结 26 2332
礼貌的吻别
礼貌的吻别 2020-11-28 17:50

I am new to Laravel. Please excuse the newbie question but how do I find if a record exists?

$user = User::where(\'em         


        
26条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 18:17

    This will check if requested email exist in the user table:

    if (User::where('email', $request->email)->exists()) {
       //email exists in user table
    }
    

提交回复
热议问题