From b10441c92867d58d3b80cf97d07549614942a21e Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 11 Jul 2024 16:01:18 +0100 Subject: [PATCH] Detach associated pivot records Signed-off-by: snipe --- app/Http/Controllers/Consumables/ConsumablesController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/Consumables/ConsumablesController.php b/app/Http/Controllers/Consumables/ConsumablesController.php index e438e33bc..f6b4f0139 100644 --- a/app/Http/Controllers/Consumables/ConsumablesController.php +++ b/app/Http/Controllers/Consumables/ConsumablesController.php @@ -182,6 +182,7 @@ class ConsumablesController extends Controller return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.not_found')); } $this->authorize($consumable); + $consumable->users()->detach(); $consumable->delete(); // Redirect to the locations management page return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.delete.success'));