|
|
|
@ -375,4 +375,51 @@ class ParkingSpaceController extends BaseController |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function store(Request $request): JsonResponse |
|
|
|
{ |
|
|
|
$data = $request->all(); |
|
|
|
if (ParkingSpace::query()->where('number', $data['number']) |
|
|
|
->exists() |
|
|
|
) { |
|
|
|
return $this->responseService->systemError('车位号码已存在'); |
|
|
|
} |
|
|
|
$floor_id = AdminFloor::query()->where('name', $data['floor_name']) |
|
|
|
->value('id'); |
|
|
|
if (!$floor_id) { |
|
|
|
return $this->responseService->systemError('楼层不存在'); |
|
|
|
} |
|
|
|
$space_attr_id = ParkingSpaceAttributes::query()->where( |
|
|
|
'attributes', |
|
|
|
$data['attr_name'] |
|
|
|
)->value('id'); |
|
|
|
if (!$space_attr_id) { |
|
|
|
return $this->responseService->systemError('车位属性不存在'); |
|
|
|
} |
|
|
|
$space_type_id = ParkingSpaceType::getValueId($data['type_name']); |
|
|
|
if (!$space_type_id) { |
|
|
|
return $this->responseService->systemError('车位类型不存在'); |
|
|
|
} |
|
|
|
$license_plate_id = 0; |
|
|
|
$status = 0; |
|
|
|
if (isset($data['license_plate'])) { |
|
|
|
$license_plate_id = ParkingLicensePlate::getValueId( |
|
|
|
$data['license_plate'] |
|
|
|
); |
|
|
|
if ($license_plate_id) { |
|
|
|
$status = 1; |
|
|
|
} else { |
|
|
|
return $this->responseService->systemError('车牌号码不存在'); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->service->createData([ |
|
|
|
'floor_id' => $floor_id, |
|
|
|
'number' => $data['number'], |
|
|
|
'space_attr_id' => $space_attr_id, |
|
|
|
'space_type_id' => $space_type_id, |
|
|
|
'license_plate_id' => $license_plate_id, |
|
|
|
'status' => $status |
|
|
|
]); |
|
|
|
return $this->responseService->success('', __('admin.operation_successful')); |
|
|
|
} |
|
|
|
} |
|
|
|
|