hasOne(User::class, 'user_id', 'user_id'); } /** * 身份证正面图片 * @return HasOne */ public function cardFrontImg(): HasOne { return $this->hasOne(UploadFile::class, 'file_id', 'card_front_img_id') ->bind(['card_front_img' => 'preview_url']); } /** * 身份证反面图片 * @return HasOne */ public function cardBackImg(): HasOne { return $this->hasOne(UploadFile::class, 'file_id', 'card_back_img_id') ->bind(['card_back_img' => 'preview_url']); } /** * 营业执照 * @return HasOne */ public function licenseImg(): HasOne { return $this->hasOne(UploadFile::class, 'file_id', 'license_img_id') ->bind(['license_img' => 'preview_url']); } /** * 门头照片 * @return HasOne */ public function doorImg(): HasOne { return $this->hasOne(UploadFile::class, 'file_id', 'door_img_id') ->bind(['door_img' => 'preview_url']); } /** * @notes:地区名称 * @param $value * @param $data * @return array * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author: wanghousheng */ public function getRegionAttr($value, $data): array { return [ 'province' => RegionModel::getNameById($data['province_id']), 'city' => RegionModel::getNameById($data['city_id']), ]; } public function getStatusTextAttr($value, $data) { // 状态 $result = WholesalerEnum::data(); if (!empty($result[$data['status']]['name'])) { return $result[$data['status']]['name']; } return '未知'; } }