Lucas Lopes Lucas Lopes - 1 year ago 237
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download