Skip to content

Commit

Permalink
Improved link deletion, by removing empty and orphan groups
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed May 31, 2024
1 parent 8d7e7a9 commit f835f14
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Http/Controllers/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ public function store(CreateLink $request)

public function destroy(LinkGroupItem $linkGroupItem)
{
$group = $linkGroupItem->group;
$linkGroupItem->delete();
if ($group?->items->isEmpty() || $group?->items->count() === 1) {
$group->delete();
}

flash()->success(__('The link has been deleted.'));

return redirect()->back();
Expand Down

0 comments on commit f835f14

Please sign in to comment.