Hi Guys.
I have made a super-admin role from the CLI, how can I assign this role to the user that is superadmin?
No users has any permission or anything yet, I have not created a GUI for this, and i belived i could just do it from the CLI as well, but that's not the case.
Sorry for the stupid question.
php artisan tinker
$user = \App\User::find(1);
then:
From the README: https://github.com/spatie/laravel-permission#using-permissions-via-roles
$user->assignRole('writer'); ... where writer could be super-duper-admin-role or whatever the role name.
Thanks dr byte.
Actually I had tried to select the user this way: $user = App\User::where('id',1)->get();
And then it throwed an error, but your suggestion got it all to work. 馃憤
@tripex just for info, get() would return a collection of one user. You needed to have used first(). The App may also have needed a back-slaseh profix () but I'm not sure what namespace tinker runs in, so maybe not.
Most helpful comment
php artisan tinker$user = \App\User::find(1);then:
From the README: https://github.com/spatie/laravel-permission#using-permissions-via-roles
$user->assignRole('writer');... wherewritercould besuper-duper-admin-roleor whatever the role name.