Eager load relations to determine

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2024-02-20 22:25:00 +00:00
parent 71610fb20f
commit 04891c7c61
2 changed files with 14 additions and 6 deletions
+6 -1
View File
@@ -289,7 +289,12 @@ class LocationsController extends Controller
// Make sure some IDs have been selected
if ((is_array($locations_raw_array)) && (count($locations_raw_array) > 0)) {
$locations = Location::whereIn('id', $locations_raw_array)->get();
$locations = Location::whereIn('id', $locations_raw_array)
->withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count')
->withCount('rtd_assets as rtd_assets_count')
->withCount('children as children_count')
->withCount('users as users_count')->get();
$valid_count = 0;
foreach ($locations as $location) {