Skip to content

Commit

Permalink
fix: delete action bug
Browse files Browse the repository at this point in the history
It gives an error because the collection to be deleted is linked to the ‘Customer Group’ table and the foreign key index.
  • Loading branch information
ferdiunal authored Oct 5, 2024
1 parent 99ad94e commit e0703f5
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public function setUp(): void
return Collection::find($arguments['id']);
});

$this->action(function (): void {
$result = $this->process(function (Collection $record) {
$record->customerGroups()->detach();
return $record->delete();
});

if (! $result) {
$this->failure();

return;
}

$this->success();
});

$this->label(
__('lunarpanel::actions.collections.delete.label')
);
Expand Down

0 comments on commit e0703f5

Please sign in to comment.