Video.php 697 B

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