CustomersSubscribe.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class CustomersSubscribe extends Model
  9. {
  10. protected $type = [
  11. 1 => '到店',
  12. 2 => '活动',
  13. 3 => '量房'
  14. ];
  15. public function getTypeAttr($value, $data)
  16. {
  17. if ($data['state'] == 0)
  18. return '预约' . $this->type[$value];
  19. if ($data['state'] < 0)
  20. return '已取消' . $this->type[$value];
  21. if ($data['state'] > 0)
  22. return '已' . $this->type[$value];
  23. }
  24. public function setTypeAttr($value)
  25. {
  26. $k = array_search($value, $this->type);
  27. if ($k === false) $k = 1;
  28. return $k;
  29. }
  30. public function customer()
  31. {
  32. return $this->belongsTo(Customer::class, 'customer_id');
  33. }
  34. public function org()
  35. {
  36. return $this->belongsTo(Org::class, 'org_id');
  37. }
  38. public function employee()
  39. {
  40. return $this->belongsTo(Employee::class, 'employee_id');
  41. }
  42. public function designer()
  43. {
  44. return $this->belongsTo(Employee::class, 'designer_id');
  45. }
  46. public function activity()
  47. {
  48. return $this->belongsTo(Activity::class, 'aid');
  49. }
  50. }