Laravel 5.2.2和Entrust错误调用未定义的方法

问题描述:

嗨,大家在使用最新的Laravel 5.2.2和Entrust(“zizaco/entrust”:“5.2.x-dev”)我面对这个错误,不知道如何解决这Laravel 5.2.2和Entrust错误调用未定义的方法

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

我测试此代码对HomeController.php

use Entrust; 

class HomeController extends Controller 
{ 


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

     return view('home'); 
    } 
} 

这是我的配置/ app.php服务提供商

Zizaco\Entrust\EntrustServiceProvider::class 

配置/app.php门面别名

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

我也已经生成模型需要

enter image description here

enter image description here

enter image description here

难道我在这里错过了什么?在此先感谢

似乎所有的步骤是正确的,我只需要清除缓存与php artisan config:cache

而且,如果你面对像下面

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

你需要改变错误。 env中这条线阵列

CACHE_DRIVER=array 
+0

我有同样的错误。我试图通过更改.env文件中的CACHE_DRIVER =数组,并在配置/缓存文件'默认'=> env('CACHE_DRIVER','数组'),但我有新的错误'[Symfony \ Component \ Debug \ Exception \ FatalErrorException] 未找到'App \ Permission'类'你能帮我吗? – user2480902

尝试这种情况:

打开你的laravel的环境文件将CACHE_DRIVER = file改为CACHE_DRIVER = array并保存。

现在尝试您的CLI命令。

我有同样的问题,这里有我已经采取措施来解决这一问题

在你.ENV文件更改到缓存阵列

CACHE_DRIVER=array 

的步骤,不要忘记运行

php artisan config:cache 
+0

即使使用'array'或'memcached',我也会遇到问题(请参阅https://github.com/Zizaco/entrust/issues/679#issuecomment-293126444)。 – Ryan

+0

尝试清除后捕获并重置您的配置使用工匠 –

+0

哦这里是我的错误:http://stackoverflow.com/questions/37462365/laravel-cache-store-does-not-support-tagging/37463070?noredirect=1 #comment73760715_37463070谢谢! – Ryan

Laravel驱动程序不支持标记。为了解决这个问题,去你.env文件并更改

Cache_driver=file 

Cache_driver=array 

和运行

php artisan config:cache