Monday, March 20, 2017

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

When I use auth()->user()->roles() with tinker it works without any problem but when I use it on the web page itself I get:

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

What does this mean, what could be the reason for this? Here is the related model:

class User extends Authenticatable
{
    public function roles(){
        return Role::where('id', 6);
    }
}



via Skeletor

Advertisement