CoachQualRecord.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Models;
  3. use App\Enums\TechnicianAuthStatus;
  4. use App\Traits\HasStateText;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. use Slowlyo\OwlAdmin\Models\BaseModel as Model;
  7. /**
  8. * 技师资质认证记录
  9. */
  10. class CoachQualRecord extends Model
  11. {
  12. use HasStateText, SoftDeletes;
  13. protected $table = 'coach_qual_records';
  14. protected $guarded = [];
  15. /**
  16. * 状态枚举类
  17. */
  18. protected string $stateEnumClass = TechnicianAuthStatus::class;
  19. protected $appends = [
  20. 'qual_photo_url', // 从业资格证
  21. 'business_license_url', // 营业执照
  22. 'health_certificate_url' // 健康证
  23. ];
  24. /**
  25. * @Author FelixYin
  26. * @description 资质记录所属技师
  27. */
  28. public function coach()
  29. {
  30. return $this->belongsTo(CoachUser::class, 'coach_id', 'id');
  31. }
  32. /**
  33. * 获取从业资格证完整URL
  34. */
  35. public function getQualPhotoUrlAttribute(): ?string
  36. {
  37. return $this->qual_photo
  38. ? "/api/download?filename={$this->qual_photo}&bucket=user-avatar"
  39. : null;
  40. }
  41. /**
  42. * 获取营业执照完整URL
  43. */
  44. public function getBusinessLicenseUrlAttribute(): ?string
  45. {
  46. return $this->business_license
  47. ? "/api/download?filename={$this->business_license}&bucket=user-avatar"
  48. : null;
  49. }
  50. /**
  51. * 获取健康证完整URL
  52. */
  53. public function getHealthCertificateUrlAttribute(): ?string
  54. {
  55. return $this->health_certificate
  56. ? "/api/download?filename={$this->health_certificate}&bucket=user-avatar"
  57. : null;
  58. }
  59. }