admin-platform/rbac
Laravel RBAC package for building an admin platform with roles and permissions. Define access rules, assign roles to users, and gate routes, controllers, and UI actions to keep admin features secure and manageable.
User, Role, Permission entities).Voter, AccessControl), which Laravel can consume via symfony/security-bundle or standalone.auth() helper, Illuminate\Auth\Access\Gate).auth:admin) via custom middleware.roles, permissions, and role_hierarchy (many-to-many with inheritance).Illuminate\Http\Middleware\Authenticate) or Telescope for admin panels.artisan) can seed roles/permissions during deployment.RoleHierarchyVoter).RoleHierarchy service).Gate system, or build a custom facade?Gate/Policy system with this package’s RoleHierarchy logic.RoleHierarchy and PermissionChecker services.symfony/security-core (if not already present) for Voter and AccessControlList interfaces.symfony/security-bundle unless using Symfony’s full stack.roles table with name, description).Schema::create('roles', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('description')->nullable();
$table->timestamps();
});
role_hierarchy pivot table (many-to-many self-relationship).Gate::define(), can() checks).composer require admin-platform/rbac
php artisan vendor:publish.admin role inherits editor permissions).Gate logic in favor of RoleHierarchy.composer.json constraints).auth() (e.g., Auth::user()->hasRole('admin')).spatie/laravel-permission (avoid mixing RBAC systems).config/rbac.php (if published).roles, permissions, and role_hierarchy.admin, editor) via a seeder.AppServiceProvider:
$this->app->bind(\Sylius\Component\Security\Role\RoleHierarchy::class, function ($app) {
return new \Sylius\Component\Security\Role\RoleHierarchy($app->make('roles'));
});
public function handle(Request $request, Closure $next, string $role)
{
if (!auth()->user()->hasRole($role)) {
abort(403);
}
return $next($request);
}
app/Http/Kernel.php:
'admin' => \App\Http\Middleware\CheckRole::class,
editor inherits viewer permissions).CONTRIBUTING.md.Voter/AccessControl.spatie/laravel-activitylog for auditing role changes.debug:container to inspect bound services.\Log::debug('User roles:', ['roles' => auth()->user()->getRoles()]);
Illuminate\Support\Facades\Cache::remember).roles.name and role_hierarchy pivot tables.N+1 queries when loading user roles.How can I help you explore Laravel packages today?