Activity.php 804 B

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