123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 技师认证记录视图模型
- *
- * 包含字段:
- * - real_auth_record_id: 实名认证记录ID
- * - coach_id: 技师编号
- * - nickname: 技师昵称
- * - gender: 性别
- * - phone: 手机号
- * - portrait_images: 技术形象照
- * - coach_state: 技师状态
- * - real_auth_state: 实名认证状态
- * - id_card_images: 身份证照片
- * - auditor: 审核人
- * - audit_time: 审核时间
- * - audit_remark: 审核回执
- */
- class VCoachAuthRecord extends Model
- {
- /**
- * 关联到模型的数据表
- *
- * @var string
- */
- protected $table = 'v_coach_auth_record';
- /**
- * 表明模型是否应该被打上时间戳
- *
- * @var bool
- */
- public $timestamps = false;
- /**
- * 可以被批量赋值的属性
- *
- * @var array
- */
- protected $guarded = [];
- /**
- * 应该被追加到模型数组的访问器
- *
- * @var array
- */
- protected $appends = [
- 'portrait_images_url', // 技术形象照URL
- 'id_card_images_url', // 身份证照片URL
- 'qual_photo_url', // 从业资格证URL
- 'business_license_url', // 营业执照URL
- 'health_certificate_url', // 健康证URL
- 'avatar_url' // 头像URL
- ];
- /**
- * 获取技术形象照完整URL
- */
- public function getPortraitImagesUrlAttribute(): ?array
- {
- if (!$this->portrait_images) {
- return null;
- }
- $images = is_string($this->portrait_images)
- ? json_decode($this->portrait_images, true)
- : $this->portrait_images;
- return array_map(function ($image) {
- return "/api/download?filename={$image}&bucket=user-avatar";
- }, $images);
- }
- /**
- * 获取身份证照片完整URL
- */
- public function getIdCardImagesUrlAttribute(): ?array
- {
- if (!$this->id_card_images) {
- return null;
- }
- $images = is_string($this->id_card_images)
- ? json_decode($this->id_card_images, true)
- : $this->id_card_images;
- return array_map(function ($image) {
- return "/api/download?filename={$image}&bucket=user-avatar";
- }, $images);
- }
- /**
- * 获取从业资格证完整URL
- */
- public function getQualPhotoUrlAttribute(): ?string
- {
- return $this->qual_photo
- ? "/api/download?filename={$this->qual_photo}&bucket=user-avatar"
- : null;
- }
- /**
- * 获取营业执照完整URL
- */
- public function getBusinessLicenseUrlAttribute(): ?string
- {
- return $this->business_license
- ? "/api/download?filename={$this->business_license}&bucket=user-avatar"
- : null;
- }
- /**
- * 获取健康证完整URL
- */
- public function getHealthCertificateUrlAttribute(): ?string
- {
- return $this->health_certificate
- ? "/api/download?filename={$this->health_certificate}&bucket=user-avatar"
- : null;
- }
- /**
- * 获取头像完整URL
- */
- public function getAvatarUrlAttribute(): ?string
- {
- return $this->avatar
- ? "/api/download?filename={$this->avatar}&bucket=user-avatar"
- : null;
- }
- /**
- * 关联技师用户
- */
- public function coach()
- {
- return $this->belongsTo(CoachUser::class, 'coach_id', 'id');
- }
- }
|