VCoachList.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Models;
  3. use App\Enums\TechnicianLevel;
  4. use App\Enums\TechnicianStatus;
  5. use App\Enums\TechnicianWorkStatus;
  6. use Illuminate\Database\Eloquent\Model;
  7. class VCoachList extends Model
  8. {
  9. protected $table = 'v_coach_list';
  10. public $timestamps = false;
  11. protected $casts = [
  12. 'id' => 'integer',
  13. 'gender' => 'integer',
  14. 'birthday' => 'datetime',
  15. 'created_at' => 'datetime',
  16. 'state' => 'integer',
  17. 'is_vip' => 'integer',
  18. 'vip_time' => 'timestamp',
  19. 'level' => 'integer',
  20. 'score' => 'float',
  21. 'work_status' => 'integer',
  22. 'virtual_order' => 'integer',
  23. 'total_income' => 'decimal:2',
  24. 'total_expense' => 'decimal:2',
  25. 'total_balance' => 'decimal:2',
  26. 'available_balance' => 'decimal:2',
  27. 'frozen_amount' => 'decimal:2',
  28. 'avatar' => 'array',
  29. 'qual_photo' => 'array',
  30. 'business_license' => 'array',
  31. 'health_certificate' => 'array',
  32. 'id_card_front_photo' => 'array',
  33. 'id_card_back_photo' => 'array',
  34. 'formal_photo' => 'string',
  35. 'health_cert' => 'array',
  36. ];
  37. protected $appends = [
  38. 'state_text',
  39. 'level_text',
  40. 'work_status_text',
  41. ];
  42. public function getStateTextAttribute()
  43. {
  44. return is_null($this->state) ? null : TechnicianStatus::fromValue($this->state)?->label();
  45. }
  46. public function getLevelTextAttribute()
  47. {
  48. return is_null($this->level) ? null : TechnicianLevel::fromValue($this->level)?->label();
  49. }
  50. public function getWorkStatusTextAttribute()
  51. {
  52. return is_null($this->work_status) ? null : TechnicianWorkStatus::fromValue($this->work_status)?->label();
  53. }
  54. }