如何分配多个角色和多个基于角色的权限uning laravel spatie?
How to assign multiple roles and multiple roles based permissions uning laravel spatie?
我正在开发一个 laravel 项目,该项目具有对以下用户的基于角色的访问权限:
1 admin -> all permissions
2 creator -> add, edit and remove members
3 finance -> add fund, update fund
the problem is, a user, say "XYZ" has multiple roles like creator and finance and another user "PQR" has only finance
通过使用“Spatie laravel 许可”,我该如何实现?
对于用户“XYZ”
我们可以将相关角色creator和finance作为数组传递给controller,
那么,
$user->assignRole($request->role);
// $user->assignRole(['creator', 'finanace']) 或 $user->assignRole('creator','finance' )
对于用户“PQR”
同上,
$user->assignRole($request->role);
// $user->assignRole(['finance']);
更多详细信息,您可以参考官方文档。 https://spatie.be/docs/laravel-permission/v3/basic-usage/role-permissions
我正在开发一个 laravel 项目,该项目具有对以下用户的基于角色的访问权限:
1 admin -> all permissions
2 creator -> add, edit and remove members
3 finance -> add fund, update fund
the problem is, a user, say "XYZ" has multiple roles like creator and finance and another user "PQR" has only finance
通过使用“Spatie laravel 许可”,我该如何实现?
对于用户“XYZ”
我们可以将相关角色creator和finance作为数组传递给controller,
那么,
$user->assignRole($request->role);
// $user->assignRole(['creator', 'finanace']) 或 $user->assignRole('creator','finance' )
对于用户“PQR”
同上,
$user->assignRole($request->role);
// $user->assignRole(['finance']);
更多详细信息,您可以参考官方文档。 https://spatie.be/docs/laravel-permission/v3/basic-usage/role-permissions