Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.2.2 and Entrust error call to undefined method

When I am using latest Laravel 5.2.2 and Entrust ("zizaco/entrust": "5.2.x-dev") I face this error and not sure how to solve this:

Call to undefined method Zizaco\Entrust\EntrustServiceProvider::hasRole()

I tested this code on HomeController.php

use Entrust;

class HomeController extends Controller
{ 


    public function index()
    {
        if (Entrust::hasRole('admin')) {
            echo "string";
        }

        return view('home');
    }
}

This is my config/app.php service provider

Zizaco\Entrust\EntrustServiceProvider::class

config/app.php facade alias

'Entrust'   => Zizaco\Entrust\EntrustFacade::class

I also already generate the model needed

enter image description here

enter image description here

enter image description here

Did I miss something here?

like image 316
cyberfly Avatar asked Dec 07 '22 23:12

cyberfly


2 Answers

I have same issue, here are the steps I have taken to solve the issue

In your .env file change to cache array

CACHE_DRIVER=array

and dont forget to run

php artisan config:cache
like image 154
Nikunj K. Avatar answered Dec 11 '22 12:12

Nikunj K.


It seems all the steps is correct, and I just need to clear the cache with php artisan config:cache

And if you face an error like below

BadMethodCallException in vendor\laravel\framework\src\Illuminate\Cache\Repository.php line 380:
This cache store does not support tagging.

You need to change in .env this line to array

CACHE_DRIVER=array
like image 30
cyberfly Avatar answered Dec 11 '22 10:12

cyberfly