我正在使用 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)