diff --git a/app/Services/ParkingPatternSpaceService.php b/app/Services/ParkingPatternSpaceService.php index 77cf30f..4dcd7bb 100644 --- a/app/Services/ParkingPatternSpaceService.php +++ b/app/Services/ParkingPatternSpaceService.php @@ -27,9 +27,11 @@ class ParkingPatternSpaceService extends BaseService { try { DB::beginTransaction(); - if (ParkingPatternSpace::query()->where('space_id', $data['parking_space_id']) - ->exists() - ) { + $where = [ + 'space_id' => $data['parking_space_id'], + 'pattern_id' => $data['pattern_id'] + ]; + if (ParkingPatternSpace::query()->where($where)->exists()) { throw new Exception(__('service.parking_pattern.space_exists')); } if (!ParkingSpace::getNumber($data['parking_space_id'])) { @@ -135,4 +137,20 @@ class ParkingPatternSpaceService extends BaseService throw $e; } } + + public static function getPatternSpaceTypeData() + { + $pattern_id = EventCalendarService::getTargetModeId(); + if ($pattern_id) { + $type_ids = ParkingPatternSpace::query()->where( + 'pattern_id', + $pattern_id + )->groupBy('space_type_id')->pluck('space_type_id'); + if ($type_ids) { + return ParkingSpaceType::query()->whereIn('id', $type_ids) + ->select(['id as space_type_id', 'name as space_type'])->get()->toArray(); + } + } + return []; + } }