BrokerNotice.php 700 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class BrokerNotice extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'title' => 'string',
  10. 'details' => 'string',
  11. 'priority' => 'int',
  12. 'createtime' => 'int',
  13. 'status' => 'tinyint',
  14. 'volume' => 'int'
  15. ];
  16. // 设置字段自动转换类型
  17. protected $type = [
  18. 'createtime' => 'timestamp:Y-m-d H:i:s'
  19. ];
  20. public function getStatusTextAttr($value,$data)
  21. {
  22. $status = [1=>'已发布',2=>'待修改'];
  23. return $status[$data['status']];
  24. }
  25. public function getCreatetimeTextAttr($value,$data)
  26. {
  27. return date('Y-m-d H:i', $data['createtime']);
  28. }
  29. }