label(__('filament-actions::detach.single.label')); $this->modalHeading(fn (): string => __('filament-actions::detach.single.modal.heading', ['label' => $this->getRecordTitle()])); $this->modalSubmitActionLabel(__('filament-actions::detach.single.modal.actions.detach.label')); $this->successNotificationTitle(__('filament-actions::detach.single.notifications.detached.title')); $this->color('danger'); $this->icon('heroicon-m-x-mark'); $this->requiresConfirmation(); $this->modalIcon('heroicon-o-x-mark'); $this->action(function (): void { $this->process(function (Model $record, Table $table): void { /** @var BelongsToMany $relationship */ $relationship = $table->getRelationship(); if ($table->allowsDuplicates()) { $record->{$relationship->getPivotAccessor()}->delete(); } else { $relationship->detach($record); } }); $this->success(); }); } }