Coach.php 829 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Coach extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'agentid' => 'int',
  10. 'title' => 'string',
  11. 'content' => 'string',
  12. 'num' => 'int',
  13. 'status' => 'tinyint',
  14. 'coachtime' => 'date',
  15. 'createtime' => 'int',
  16. ];
  17. // 设置字段自动转换类型
  18. protected $type = [
  19. 'createtime' => 'timestamp:Y-m-d H:i',
  20. ];
  21. public static $status = [1 => '待审核', 2 => '优秀', 3 => '合格', 4 => '不合格'];
  22. public function getStatusTextAttr($value, $data)
  23. {
  24. return self::$status[$data['status']];
  25. }
  26. public function agent()
  27. {
  28. return $this->hasOne(Agent::class, 'id', 'agentid');
  29. }
  30. }