Worder.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Worder extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'cateid' => 'int',
  10. 'workerid' => 'int',
  11. 'title' => 'string',
  12. 'tags' => 'string',
  13. 'otype' => 'string',
  14. 'wagall' => 'string',
  15. 'telephone' => 'string',
  16. 'province' => 'string',
  17. 'city' => 'string',
  18. 'district' => 'string',
  19. 'jobdetails' => 'string',
  20. 'coodetails' => 'string',
  21. 'status' => 'tinyint',
  22. 'priority' => 'int',
  23. 'updatetime' => 'int',
  24. 'createtime' => 'int',
  25. 'volume' => 'int'
  26. ];
  27. // 设置字段自动转换类型
  28. protected $type = [
  29. 'tags' => 'json',
  30. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  31. 'createtime' => 'timestamp:Y-m-d H:i:s'
  32. ];
  33. // 设置JSON数据返回数组
  34. protected $jsonAssoc = true;
  35. public function getStatusTextAttr($value,$data)
  36. {
  37. $status = [1=>'待修改',2=>'待审核',3=>'未通过',4=>'已上架',5=>'已下架'];
  38. return $status[$data['status']];
  39. }
  40. // 关联WorderCate
  41. public function worderCate()
  42. {
  43. return $this->hasOne(WorderCate::class, "id", "cateid");
  44. }
  45. // 关联Worker
  46. public function worker()
  47. {
  48. return $this->hasOne(Worker::class, "id", "workerid");
  49. }
  50. // 关联WorderLog
  51. public function worderLog()
  52. {
  53. return $this->hasMany(WorderLog::class, "worderid", "id");
  54. }
  55. }