Eloquent ->first() if ->exists()

前端 未结 5 598
天涯浪人
天涯浪人 2020-12-23 09:08

I want to get the first row in table where condition matches:

User::where(\'mobile\', Input::get(\'mobile\'))->first()

It works well, bu

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 10:01

    Try it this way in a simple manner it will work

    $userset = User::where('name',$data['name'])->first();
    if(!$userset) echo "no user found";
    

提交回复
热议问题