From 74088ea5813b0ccdb4b6c58e375f41bb19ecae29 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 19 Sep 2024 20:13:38 +0100 Subject: [PATCH] Optimize isDeletable counts Signed-off-by: snipe --- app/Models/Manufacturer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 6fe7426514..6e72b3a2bb 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -74,10 +74,10 @@ class Manufacturer extends SnipeModel public function isDeletable() { return Gate::allows('delete', $this) - && ($this->assets()->count() === 0) - && ($this->licenses()->count() === 0) - && ($this->consumables()->count() === 0) - && ($this->accessories()->count() === 0) + && (($this->assets_count ?? $this->assets()->count()) === 0) + && (($this->licenses_count ?? $this->licenses()->count()) === 0) + && (($this->consumables_count ?? $this->consumables()->count()) === 0) + && (($this->accessories_count ?? $this->accessories()->count()) === 0) && ($this->deleted_at == ''); }