get('building_floor', 1); $pattern_id = $request->get('pattern_id', 1); $floorData = AdminFloor::query()->where( 'building_floor', $building_floor )->select(['id', 'name'])->get()->toArray(); foreach ($floorData as $item) { $floor_id = $item['id']; $floor_name = $item['name']; $sum_count = ParkingSpace::query()->where('floor_id', $floor_id) ->count(); $vacant_count = ParkingSpace::query()->where( ['floor_id' => $floor_id, 'status' => 0] )->count(); $repair_count = ParkingSpace::query()->where( ['floor_id' => $floor_id, 'status' => 2] )->count(); $typeData = ParkingSpaceType::getData(); $type_list = []; foreach ($typeData as $typeItem) { $spaceWhere = [ 'floor_id' => $floor_id, 'space_type_id' => $typeItem['id'] ]; $type_count = ParkingSpace::query()->where($spaceWhere) ->count(); $type_list[] = [ 'count' => $type_count, 'name' => $typeItem['name'] ]; } $data[] = [ 'floor_name' => $floor_name, 'sum_count' => $sum_count, 'vacant_count' => $vacant_count, 'parking_space_type_list' => $type_list, 'repair_count' => $repair_count ]; } return $this->responseService->success($data); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } public function parkingSpaceStatistics(Request $request) { try { $pattern_id = $request->get('pattern_id', 1); $sum = ParkingSpace::query()->count(); $use_sum = ParkingSpace::query()->where('status', 1)->count(); $date['proportion'] = get_ratio($sum, $use_sum); return $this->responseService->success($date); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } public function menu(): JsonResponse { try { $data = (new AdminMenuService( new OperationLogService() ))->getUserMenuTreeList( $this->adminUserId ); return $this->responseService->success($data); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } }