Lucas Lopes Lucas Lopes - 3 months ago 36
PHP Question

Call to undefined method Laravel Defender

I'm using Laravel 5.1.*. Installed defender and created my role 'admin'...But when will using the middleware 'needsRole' (in routes.php) or 'Defender::hasRole('admin')' (in controller) not working.

Message error

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

Answer

make sure of two things use the trait in your model Artesaos\Defender\Traits\HasDefender and register the service provider then do a composer dump-autoload