laravel - spatie 在 null 上调用成员函数 contains()?
问题描述
我将 spatie 安装到 Laravel 权限:
但是当我试图检查用户是否有 rule 时,出现了这个问题:
Call to a member function contains() on null?
我的代码是:
@role('Admin')
<p>This message appears if the user is an admin </p>
@endrole
注意:如果我检查使用这样的权限:
@can('show-post')
<p>This message appears if the user is an admin </p>
@endcan
它工作,为什么使用角色不起作用?
解决方案
推荐阅读
- javascript - 使用 JavaScript 创建 16x16 网格
- linux-kernel - 我应该手动编辑`.config`文件以禁用Linux内核中的`AUDITSYSCALL`吗?
- arrays - VBA,此“x = Array()”的替代代码
- excel - 使用 VBA 循环遍历特定列
- ios - 你如何实现,firebase完成这个源
- php - 使用资源显示数据后分页不显示
- c++ - 这个 if 语句有什么捷径吗?
- python - Numpy reshaping 2D to 3D: moving columns to "depth"
- azure - 在多个区域创建 Azure VM
- reactjs - 如何使用 Timer 响应性能优化重新渲染?