From 5882d71f9b1406358e54bddc6c5277ba5512689b Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 5 Feb 2024 15:55:53 +0000 Subject: [PATCH] Fix company asset counts for dashboard widget Signed-off-by: snipe --- app/Http/Controllers/Api/CompaniesController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index 580bc5d9b9..9c667973a3 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -40,7 +40,9 @@ class CompaniesController extends Controller 'components_count', ]; - $companies = Company::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count'); + $companies = Company::withCount(['assets as assets_count' => function ($query) { + $query->AssetsForShow(); + }])->withCount('licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count'); if ($request->filled('search')) { $companies->TextSearch($request->input('search'));