Train.php 653 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Train extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'title' => 'string',
  10. 'contact' => 'string',
  11. 'mobile' => 'string',
  12. 'address' => 'string',
  13. 'create_time' => 'int',
  14. 'priority' => 'int',
  15. ];
  16. // 设置字段自动转换类型
  17. protected $type = [
  18. 'create_time' => 'timestamp:Y-m-d H:i',
  19. ];
  20. public function getStatusTextAttr($value, $data)
  21. {
  22. $status = [1 => '显示', 2 => '隐藏'];
  23. return $status[$data['status']];
  24. }
  25. }