I make a request:

User::where('uid',$userInfo['uid'])->isEmpty(); 

I get the error:

 BadMethodCallException in Builder.php line 2123: Call to undefined method Illuminate\Database\Query\Builder::isEmpty() 

Is it even possible to do this?

    1 answer 1

    This method is not in the builder, there are several options:

    1. Through the method exists (the best for me):

       if (User::where('uid',$userInfo['uid'])->exists()) { //Запись существует } 
    2. Through the count method:

       if (User::where('uid',$userInfo['uid'])->count() > 0) { //Запись существует } 
    3. By simple sampling first and checking for null:

       $user = User::where('uid',$userInfo['uid'])->first(); if ($user != null) { // Запись существует }