Add multiple roles to a user and handle their policies
untitledpng/laravel-policy-roles is a Laravel package for add multiple roles to a user and handle their policies.
It currently has 0 GitHub stars and 96 downloads on Packagist (latest version v2.1.0).
Install it with composer require untitledpng/laravel-policy-roles.
Discover more Laravel packages by untitledpng
or browse all Laravel packages to compare alternatives.
Last updated
With this package you can have role based permissions. When the role does not exist, this package will automatically prevent access. This package also supports Laravel Nova out of the box.
Install the package using composer composer require untitledpng/laravel-policy-roles.
Untitledpng\LaravelPolicyRoles\Domain\User.AuthServiceProvider like you normally would.use Untitledpng\LaravelPolicyRoles\Services\PolicyService;
class UserPolicy extends Untitledpng\LaravelPolicyRoles\Policies\BasePolicy
{
/**
* UserPolicy constructor.
*
* @param PolicyService $policyService
*/
public function __construct(
\Untitledpng\LaravelPolicyRoles\Services\PolicyService $policyService
) {
parent::__construct('user', $policyService);
}
}
$user->hasRole('view-user'); This will return true/ false based on if the user has that role.@can('create', App\User::class) YES @endcan to check if the user has a specific permission.