1. Go to this page and download the library: Download callcocam/inertia-rbac library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
callcocam / inertia-rbac example snippets
use Callcocam\InertiaRbac\Concerns\HasRbac;
class User extends Authenticatable
{
use HasRbac; // HasRoles (Spatie) + HasUlids + isSuperAdmin()
}
use Callcocam\InertiaRbac\Concerns\ChecksRbacPermission;
class ProductPolicy
{
use ChecksRbacPermission;
public function viewAny($user): bool { return $this->allowByContext($user, 'products.viewAny'); }
public function create($user): bool { return $this->allowByContext($user, 'products.create'); }
// ...
}