I'm working with Laravel 5.6 and Spatie laravel-permission and I want to modify the model_has_roles
so it can have an extra field named code
.
Now, i did that thing by modifying the migrations the library provides via the next command:
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"
This library provides a useful command:
$user->assignRole($role);
That lets me assign a role to an user within a single line of code. My problem is that, using this command will throw an error because i can't leave the code
field empty. Either way, i can't do something like this:
$user->assignRole($role, ['code' => '0001']
);
Because it will say that 0001 is not a role
. Basically, it asumes that i'm trying to assign TWO different roles to the user: $role
and 0001
while actually i'm trying to assign a single role: $role
with an extra parameter for the table model_has_roles
.
Is there a way to archieve such a thing? I thought that maybe i could modify the logic behind the assignRole
method but i don't know how to extend/edit the library methods.