From 889d5da71ebcfc4048b0183b0c977dbb6b94f396 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 7 Aug 2024 20:04:32 +0100 Subject: [PATCH] Check for accessories on bulk items Signed-off-by: snipe --- app/Http/Controllers/Api/LocationsController.php | 1 + app/Models/Location.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 73227e0825..9b07813f76 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -248,6 +248,7 @@ class LocationsController extends Controller ->withCount('rtd_assets as rtd_assets_count') ->withCount('children as children_count') ->withCount('users as users_count') + ->withCount('checkouts as accessories_count') ->findOrFail($id); if (! $location->isDeletable()) { diff --git a/app/Models/Location.php b/app/Models/Location.php index 67131902a1..b03fae60d9 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -111,6 +111,7 @@ class Location extends SnipeModel && ($this->assets_count === 0) && ($this->assigned_assets_count === 0) && ($this->children_count === 0) + && ($this->accessories_count === 0) && ($this->users_count === 0); }