Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ynoth25's avatar

Laravel Spatie Permission

I have existing roles that i want to add / link another permission using artisan command.

The documentation only says linking permission and creating a role can be done at the same time, is there anyway i can link / add permission to existing roles using artisan command?

0 likes
2 replies
rohit_mg's avatar

have you tried either of these

$role->givePermissionTo($permission);
$permission->assignRole($role);

they aren't artisan commands, but you should be able to run it in a controller or in tinker so that the relevant Spatie roles and permissions tables are updated

SilenceBringer's avatar

@ynoth25 I do not think artisan command exists to directly assign permission to roles. But you can use tinker to quickly do it

Firstly run in console

php artisan tinker

and then step by step

$role = \Spatie\Permission\Models\Role::where('name', 'YourRoleName')->first();
$permission = \Spatie\Permission\Models\Permission::where('name', 'YourPermissionName')->first();
$role->givePermissionTo($permission);

// or

$permission->assignRole($role);

Please or to participate in this conversation.