4

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?

peterh
  • 11,875
  • 18
  • 85
  • 108
cyberfly
  • 5,568
  • 8
  • 50
  • 67

4 Answers4

11

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
Nikunj K.
  • 8,779
  • 4
  • 43
  • 53
  • I get the problem even using `array` or `memcached` (see https://github.com/Zizaco/entrust/issues/679#issuecomment-293126444). – Ryan Apr 11 '17 at 01:51
  • Try after clear you catch and reset your config using artisan – Nikunj K. Apr 11 '17 at 11:01
  • Ohh here was my mistake: http://stackoverflow.com/questions/37462365/laravel-cache-store-does-not-support-tagging/37463070?noredirect=1#comment73760715_37463070 Thank you! – Ryan Apr 11 '17 at 14:26
4

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
cyberfly
  • 5,568
  • 8
  • 50
  • 67
  • i had same error. i have tried by changing CACHE_DRIVER=array in .env file and also in config/cache file 'default' => env('CACHE_DRIVER', 'array') but i have got new error `[Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\Permission' not found ` can you help me? – ofaruk Jun 01 '16 at 18:08
0

Try this:

Open environment file of your laravel change CACHE_DRIVER=file to CACHE_DRIVER=array and save.

Now try your CLI command.

-1

Laravel drivers does not support tagging. To solve this, go to your .env file and change

Cache_driver=file

to

Cache_driver=array

and run

php artisan config:cache
drowsyTicker
  • 2,279
  • 2
  • 10
  • 17