首页 > 解决方案 > 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
 

它工作,为什么使用角色不起作用?

标签: laravellaravel-permission

解决方案


推荐阅读