WorkerForm.php 801 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class WorkerForm extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'workerid' => 'int',
  10. 'comname' => 'string',
  11. 'address' => 'string',
  12. 'details' => 'string',
  13. 'realname' => 'string',
  14. 'mobile' => 'string',
  15. 'comjobs' => 'string',
  16. 'status' => 'tinyint',
  17. 'remark' => 'string',
  18. 'createtime' => 'int'
  19. ];
  20. // 设置字段自动转换类型
  21. protected $type = [
  22. 'createtime' => 'timestamp:Y-m-d H:i:s'
  23. ];
  24. public function getStatusTextAttr($value,$data)
  25. {
  26. $status = [1=>'待处理',2=>'处理中',3=>'已处理'];
  27. return $status[$data['status']];
  28. }
  29. // 关联Worker
  30. public function worker()
  31. {
  32. return $this->hasOne(Worker::class, "id", "workerid");
  33. }
  34. }