Supply.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Supply extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'workerid' => 'int',
  14. 'mnumber' => 'int',
  15. 'wnumber' => 'int',
  16. 'agegroup' => 'string',
  17. 'province' => 'string',
  18. 'city' => 'string',
  19. 'district' => 'string',
  20. 'descity' => 'string',
  21. 'candate' => 'string',
  22. 'telephone' => 'string',
  23. 'remark' => 'string',
  24. 'status' => 'tinyint',
  25. 'priority' => 'int',
  26. 'updatetime' => 'int',
  27. 'createtime' => 'int',
  28. 'volume' => 'int',
  29. 'telearr' => 'string'
  30. ];
  31. // 设置字段自动转换类型
  32. protected $type = [
  33. 'telearr' => 'json',
  34. 'candate' => 'timestamp:Y-m-d',
  35. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  36. 'createtime' => 'timestamp:Y-m-d H:i:s'
  37. ];
  38. // 设置JSON数据返回数组
  39. protected $jsonAssoc = true;
  40. public function getStatusTextAttr($value,$data)
  41. {
  42. $status = [1=>'待修改',2=>'待审核',3=>'已上架',4=>'已停供',5=>'已下架'];
  43. return $status[$data['status']];
  44. }
  45. // 关联Worker
  46. public function worker()
  47. {
  48. return $this->hasOne(Worker::class, "id", "workerid");
  49. }
  50. }