传递给 Cartalyst\Sentinel\Permissions\Standard Permissions::prepare Permissions() 的参数 2 必须是数组类型,给定为 null

Argument 2 passed to Cartalyst\Sentinel\Permissions\Standard Permissions::prepare Permissions() must be of the type array, null given

我有一个配置了 Cartalyst\Sentinel (v2.0.15) 包的 Laravel 5.3 项目。我有这条线

$hasPermission = Sentinel::getUser()->hasAccess($routeName);

但我不断收到此错误消息:

Argument 2 passed to 
Cartalyst\Sentinel\Permissions\StandardPermissions::prepare Permissions() must be of the type array, null given

我查看了 Google 和软件包的 github 页面,但找不到任何可以帮助我解决此问题的信息。

当我查看包的源代码时,我看到了这段代码:

/**
 * {@inheritDoc}
 */
protected function createPreparedPermissions()
{
    $prepared = [];

    // $this->secondaryPermissions equals to:
    // [
    //     0 => NULL,
    // ]
    if (! empty($this->secondaryPermissions)) {
        foreach ($this->secondaryPermissions as $permissions) {
            // this is the line where it throws the error as $permissions == NULL
            $this->preparePermissions($prepared, $permissions);
        }
    }

    if (! empty($this->permissions)) {
        $permissions = [];

        $this->preparePermissions($permissions, $this->permissions);

        $prepared = array_merge($prepared, $permissions);
    }

    return $prepared;
}

secondaryPermissions 数组不为空。这些 'secondary' 权限是什么?我查看了 Sentinel 的文档页面,但找不到任何相关信息。我唯一能找到的是 'user' 可以拥有权限,但 'role' 也可以。我当前的数据库设置是角色具有权限,但我的 none 用户具有任何特定权限。所以我的用户 table 中的 'permissions' 字段总是等于 NULL。

谢谢。

已修复。 问题是权限未正确存储在我的数据库中。

应该是这样的:

{"controller.action": true, "controller.actionTwo": true}

而不是:

{"controller.action: true", "controller.actionTwo: true"}