gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 16:51:41 27 4
gpt4 key购买 nike

当我使用最新的 Laravel 5.2.2 和 Entrust ("zizaco/entrust": "5.2.x-dev") 时,我遇到了这个错误,不知道如何解决这个问题:

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');
}
}
这是我的 config/app.php 服务提供者
Zizaco\Entrust\EntrustServiceProvider::class
config/app.php 门面别名
'Entrust'   => Zizaco\Entrust\EntrustFacade::class
我也已经生成了所需的模型
enter image description here
enter image description here
enter image description here
我在这里错过了什么吗?

最佳答案

我有同样的问题,这是我为解决问题而采取的步骤

在您的 .env 文件中更改为缓存数组

CACHE_DRIVER=array

并且不要忘记运行
php artisan config:cache

关于Laravel 5.2.2 和 Entrust 错误调用未定义方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35738642/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com