diff --git a/app/api/controller/Recovery.php b/app/api/controller/Recovery.php index f3f99bba..c52c0c5e 100644 --- a/app/api/controller/Recovery.php +++ b/app/api/controller/Recovery.php @@ -45,11 +45,11 @@ class Recovery extends Controller /** * @notes:获取详情 - * @return Json|void + * @return Json * @throws BaseException * @author: wanghousheng */ - public function detail() + public function detail(): Json { $recoveryId = intval($this->request->post('recovery_id')); if (!$recoveryId) { @@ -57,6 +57,15 @@ class Recovery extends Controller } $model = new RecoveryOrder(); $info = $model->getDetails($recoveryId); + if ($info && !empty($info['images'])) { + $images_list = helper::getArrayColumn($info['images'], 'file'); + $arr = []; + foreach ($images_list as $image) { + $arr[] = $image['preview_url']; + } + $info['images_list'] = $arr; + unset($info['images']); + } return $this->renderSuccess(['detail' => $info]); } diff --git a/app/common/model/RecoveryOrder.php b/app/common/model/RecoveryOrder.php index 6d9fa861..3ba62b77 100644 --- a/app/common/model/RecoveryOrder.php +++ b/app/common/model/RecoveryOrder.php @@ -30,7 +30,7 @@ class RecoveryOrder extends BaseModel */ public function images(): HasMany { - return $this->hasMany('RecoveryImage')->order(['id']); + return $this->hasMany(RecoveryImage::class, 'recovery_id', 'recovery_id')->order(['id']); } public function getOrderStatusTextAttr($value, $data)