Closed beshoo closed 1 year ago
On the other hand, you can use https://github.com/blendbyte/nova-attach-many
This is a request?
If yes, it is not the pupouse of repository
I'm actually helping another user to find a way to add this functionality to another resource.
I don't undersand. Is not more easy add a HasMany relation to resource?
I'm not sure if I understand correctly, but using HasMany::make('Roles')
won't provide a select option to choose from when creating or updating a user.
No, but allows the user add multiple roles to resource as the same way.
If you want something more flexible you can you use:
https://nova.laravel.com/docs/4.0/resources/repeater-fields.html
My method is easier and will syncRoles the role on create and update..
As we know, we can not attach roles upon creation or updating. https://github.com/serenysoft/nova-permissions/issues/21
You need to go to attach method on the module page!
Well, I created a simple select while retrieving all available roles and only isSuperAdmin can see it.
To update the role we need to syncRoles! this will remove any previous role/permissions and here is the afterCreate/afterUpdate
Now once you want to create/update a record you can attach the role directly