mibo/px
PX
Permissions and their evaluating. Role Based System.
Implementation
composer require mibo/px
Requirements
- PHP ^8.0
- illuminate/support ^10.0-^12.0
Usage
// Load the user that has permissions.
/** @var \MiBo\PX\Contracts\HasPermissionsInterface $user */
$user;
if ($user->hasPermission("my.own.permission")) {
// Do some action
} else {
// You may log that the user is missing required permission.
}
When implementing the interface, consider to use provided trait. If doing so,
call registerPermissions method with all available permissions for the user:
class MyUser implements \MiBo\PX\Contracts\HasPermissionsInterface
{
use \MiBo\PX\Contracts\HasPermissionsTrait;
public function __construct()
{
$this->registerPermissions(
[
"my.own.permission",
"my.another.permission"
]
);
}
}
Related Packages
offload-project/laravel-mandate
Unified authorization management for Laravel - roles, permissions, and feature f...
2,275
7
shiwuhao/laravel-rbac
A modern Laravel 12+ RBAC package with data permissions and auto-sync features.
1,931
1
santigarcor/laratrust
This package provides a flexible way to add Role-based Permissions to Laravel
6,170,887
2,274