Laravel 5.2.2 and Entrust undefined method call error

Hi guys, when using the latest Laravel 5.2.2 and Entrust ("zizaco / entrust": "5.2.x-dev") I encounter this error and don’t know how to solve this problem.
Call to undefined method Zizaco\Entrust\EntrustServiceProvider::hasRole() 

I checked 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 alias

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

I also already created the required model

enter image description here

enter image description here

enter image description here

Did I miss something? thanks in advance

+5
source share
4 answers

I have the same problem, here are the steps I took to solve the problem.

The cache array will change in your .env file

 CACHE_DRIVER=array 

and do not forget to run

 php artisan config:cache 
+10
source

It seems that all the steps are correct, and I just need to clear the cache using php artisan config:cache

And if you encounter an error as below

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

You need to change this string in .env to an array

 CACHE_DRIVER=array 
+5
source

Try the following:

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

Now try the CLI command.

0
source

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

 Cache_driver=file 

to

 Cache_driver=array 

and run

 php artisan config:cache 
0
source

Source: https://habr.com/ru/post/1244271/


All Articles