Works and returns true in php artisan tinker:
>>> User::where('id', 1)->is('admin');
BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder\::is()'
Because when using
->where() you are building a collection, but
->first(), returns the model.
For eloquent to return the model, you need to ask it to execute the query, by adding a
This however also returns a collection. You can solve this by using
Edit for comments:
Try to do this, but the code above should work.
$user = User::where('id', 1)->first(); $isAdmin = $user->is('admin');