digitalcloud/nova-permission-tool
A Laravel Nova tool for managing roles and permissions via spatie/laravel-permission. It provides a clean Nova interface to create roles, assign permissions, and attach roles to users, letting you handle access control without leaving your admin panel.
This package is a Nova UI wrapper around spatie/laravel-permission; it does not replace Spatie. Treat Spatie as the source of truth and the tool as an admin screen for roles and permissions.
composer.json and testing a fork.composer require spatie/laravel-permission
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
composer require digitalcloud/nova-permission-tool
app/Providers/NovaServiceProvider.php:
public function tools()
{
return [
new \DigitalCloud\NovaPermissionTool\NovaPermissionTool(),
];
}
Verify the exact class name in the package README or src/ if your installed version differs.php artisan vendor:publish --provider="DigitalCloud\NovaPermissionTool\ToolServiceProvider"
php artisan nova:publish
php artisan migrate
$user->hasRole('editor');
$user->can('update posts');
Use a code-first permission catalogue and let the Nova UI manage role composition. Permissions are referenced by string in policies, middleware, and Blade, so uncontrolled permission creation in production is a common source of drift.
// database/seeders/PermissionSeeder.php
foreach ([
'view users',
'create users',
'update users',
'delete users',
] as $permission) {
Permission::findOrCreate($permission, 'web');
}
Daily workflow:
$user->syncRoles(['editor']);
$user->givePermissionTo('publish posts');
Text::make('Email')
->canSee(fn ($request) => $request->user()->can('view users'));
Route::middleware('permission:update users')->group(function () {
// ...
});
Gate::before super-admin bypass instead of assigning every permission:
Gate::before(function ($user, $ability) {
return $user->hasRole('super-admin') ? true : null;
});
BelongsToMany field or a custom action that calls syncRoles.$this->seed(PermissionSeeder::class);
app(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
composer.json constraints before installing; for modern Nova, prefer a maintained package or a small custom Nova tool.api but the tool creates web permissions, $user->can() will fail unexpectedly. Set guard_name explicitly in seeders and config.php artisan permission:cache-reset
# older versions:
php artisan cache:forget spatie.permission.cache
team_id; test carefully or bypass the UI for team assignments.canSee/authorization check so only admins can open the permissions screen.php artisan nova:publish, clear config/view caches, and check the browser console and storage/logs/nova.log.config/permission.php, run php artisan route:list | grep -i permission, and use Tinker:
$user->getAllPermissions()->pluck('name');
Role::with('permissions')->get();
How can I help you explore Laravel packages today?