From 9350a20189a261871796f89e2bb37e82b3b18cda Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 7 Aug 2024 20:19:47 +0100 Subject: [PATCH] Include accessories count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t exactly right right now Signed-off-by: snipe --- app/Http/Controllers/Api/LocationsController.php | 2 +- app/Models/Location.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 9b07813f7..10744bee2 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -248,7 +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') + ->withCount('accessories as accessories_count') ->findOrFail($id); if (! $location->isDeletable()) { diff --git a/app/Models/Location.php b/app/Models/Location.php index b03fae60d..f08a51a98 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -108,11 +108,11 @@ class Location extends SnipeModel { return Gate::allows('delete', $this) - && ($this->assets_count === 0) - && ($this->assigned_assets_count === 0) - && ($this->children_count === 0) - && ($this->accessories_count === 0) - && ($this->users_count === 0); + && ($this->assets_count == 0) + && ($this->assigned_assets_count == 0) + && ($this->children_count == 0) + && ($this->accessories_count == 0) + && ($this->users_count == 0); } /**