OfflineTypeModel.php 867 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Model;
  5. /**
  6. * 群组
  7. */
  8. class OfflineTypeModel extends BaseModel
  9. {
  10. // 表名
  11. protected $name = 'offline_type';
  12. // 自动写入时间戳字段
  13. protected $autoWriteTimestamp = 'int';
  14. // 定义时间戳字段名
  15. protected $createTime = 'createtime';
  16. protected $updateTime = 'updatetime';
  17. protected int $is_status_search = 1;// 默认使用 status = 1 筛选
  18. protected int $is_delete_search = 0;// 默认使用 is_delete = 0 筛选
  19. /**
  20. * 默认查询字段
  21. *
  22. * @var array|string[]
  23. */
  24. public array $select = [
  25. '*'
  26. ];
  27. public function searchIsHomeAttribute($query, $value, array $params)
  28. {
  29. if (!in_array($value,[0,1])) {
  30. return $query;
  31. }
  32. return $query->where('is_home', $value);
  33. }
  34. }