Make the following 2 actions
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
$model->roles()->syncWithoutDetaching($fields->role);
}
}
public function fields()
{
return [
Select::make('Role')->options(
\App\Role::all()->pluck('id', 'name')->flip()
)->rules('required')
];
}
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
$model->roles()->detach($fields->role);
}
}
public function fields()
{
return [
Select::make('Role')->options(
\App\Role::all()->pluck('id', 'name')->flip()
)->rules('required')
];
}