2016-03-02 47 views
5

嗨,大家在使用最新的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

難道我在這裏錯過了什麼?在此先感謝

回答

5

似乎所有的步驟是正確的,我只需要清除緩存與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

0

嘗試這種情況:

打開你的laravel的環境文件將CACHE_DRIVER = file改爲CACHE_DRIVER = array並保存。

現在嘗試您的CLI命令。

10

我有同樣的問題,這裏有我已經採取措施來解決這一問題

在你.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

0

Laravel驅動程序不支持標記。爲了解決這個問題,去你.env文件並更改

Cache_driver=file 

Cache_driver=array 

和運行

php artisan config:cache 
相關問題