DemandSnatch.php 845 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class DemandSnatch extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'demand_id' => 'int',
  10. 'worker_id' => 'int',
  11. 'num' => 'int',
  12. 'status' => 'int',
  13. 'createtime' => 'int',
  14. ];
  15. // 设置字段自动转换类型
  16. protected $type = [
  17. 'createtime' => 'timestamp:Y-m-d H:i:s',
  18. ];
  19. public function demand()
  20. {
  21. return $this->hasOne(Demand::class, 'id', 'demand_id');
  22. }
  23. public function worker()
  24. {
  25. return $this->hasOne(Worker::class, 'id', 'worker_id');
  26. }
  27. public function getStatusTextAttr($value,$data)
  28. {
  29. $fstatus = [1=>'待审核', 2=>'审核通过', 3=>'已完成'];
  30. return $fstatus[$data['status']];
  31. }
  32. }