小编Bar*_*zai的帖子

spatie/laravel-permission 没有名为`edit_project` 的权限用于guard `api`

我正在使用 Laravel 5.6 和 spatie/laravel-permission 2.9 版,还使用 ​​Laravel Passport 作为$guard = 'api'.

当我尝试在['edit_project', 'add_project' 'delete_project']此功能的帮助下为角色分配一系列权限时

public function assignPermissions($role, $permissions)
    {

        $role = Role::findByName($role);

        $role->givePermissionTo($permissions);

        return $role;
    }
Run Code Online (Sandbox Code Playgroud)

但得到错误There is no permission namededit_project for guardapi`。

我也在 config/auth.php

return [

/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 spatie

7
推荐指数
4
解决办法
1万
查看次数

标签 统计

laravel ×1

laravel-5 ×1

php ×1

spatie ×1