diff --git a/app/Http/Controllers/Admin/IndexController.php b/app/Http/Controllers/Admin/IndexController.php index cb20377..93253da 100644 --- a/app/Http/Controllers/Admin/IndexController.php +++ b/app/Http/Controllers/Admin/IndexController.php @@ -77,7 +77,7 @@ class IndexController extends BaseController $typeData = ParkingSpaceType::query()->whereIn( 'id', $spaceTypeIds - )->select(['id', 'name'])->get()->toArray(); + )->select(['id', 'name', 'default_color_vacant'])->get()->toArray(); } $type_list = []; foreach ($typeData as $typeItem) { @@ -85,10 +85,17 @@ class IndexController extends BaseController 'floor_id' => $floor_id, 'space_type_id' => $typeItem['id'] ]; - $type_count = ParkingSpace::query()->where($spaceWhere) + $ParkingSpace = ParkingSpace::query()->where($spaceWhere) ->whereIn('status', $statusArr) ->whereIn('id', $spaceIds) - ->count(); + ->select('status')->get()->toArray(); + $type_count = count($ParkingSpace); + $type_vacant_count = 0; + foreach ($ParkingSpace as $item) { + if ($item != 1){ + $type_vacant_count += 1; + } + } $type_name = AdminTranslationService::getTranslationTypeName( $typeItem['id'], @@ -97,6 +104,8 @@ class IndexController extends BaseController ); $type_list[] = [ 'count' => $type_count, + 'vacant_count' => $type_vacant_count, + 'type_count' => $typeItem['default_color_vacant'], 'name' => $type_name ]; }