Browse Source

添加维修车位优化2

master
wanghongjun 3 weeks ago
parent
commit
993b22a024
  1. 6
      app/Services/ParkingSpaceRepairService.php

6
app/Services/ParkingSpaceRepairService.php

@ -61,12 +61,14 @@ class ParkingSpaceRepairService extends BaseService
try { try {
DB::beginTransaction(); DB::beginTransaction();
$spaceNameArr = explode(',', $data['parking_space_name']); $spaceNameArr = explode(',', $data['parking_space_name']);
$count = count($spaceNameArr);
foreach ($spaceNameArr as $parking_space_name) { foreach ($spaceNameArr as $parking_space_name) {
$space = ParkingSpace::query()->where('number', $parking_space_name)->first(); $space = ParkingSpace::query()->where('number', $parking_space_name)->first();
$str = $count > 1 ? ':' . $parking_space_name : '';
if (!$space) { if (!$space) {
throw new CustomException( throw new CustomException(
__service($this->menuTitle . '.space_not_exists') __service($this->menuTitle . '.space_not_exists')
. ':' . $parking_space_name . $str
); );
} }
// 维修状态不可添加 // 维修状态不可添加
@ -75,7 +77,7 @@ class ParkingSpaceRepairService extends BaseService
if ($space['status'] == 2) { if ($space['status'] == 2) {
throw new CustomException( throw new CustomException(
__service($this->menuTitle . '.space_exists') __service($this->menuTitle . '.space_exists')
. ':' . $parking_space_name . $str
); );
} }
$model = $this->createData( $model = $this->createData(

Loading…
Cancel
Save