You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LiveAnchor.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\model\activity\live;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. use think\Model;
  6. /**
  7. * 主播
  8. * Class LiveAnchor
  9. * @package app\model\activity\live
  10. */
  11. class LiveAnchor extends BaseModel
  12. {
  13. use ModelTrait;
  14. protected $pk = 'id';
  15. protected $name = 'live_anchor';
  16. protected $autoWriteTimestamp = 'int';
  17. protected $createTime = 'add_time';
  18. protected function setAddTimeAttr()
  19. {
  20. return time();
  21. }
  22. /**
  23. * 添加时间获取器
  24. * @param $value
  25. * @return false|string
  26. */
  27. public function getAddTimeAttr($value)
  28. {
  29. if (!empty($value)) {
  30. return date('Y-m-d H:i:s', (int)$value);
  31. }
  32. return '';
  33. }
  34. public function room()
  35. {
  36. return $this->hasOne(LiveRoom::class, 'anchor_wechat', 'wechat');
  37. }
  38. public function searchKerwordAttr($query, $value)
  39. {
  40. if ($value !== '') $query->whereLike('id|name|wechat|phone', "%{$value}%");
  41. }
  42. /**
  43. * @param Model $query
  44. * @param $value
  45. */
  46. public function searchIsShowAttr($query, $value)
  47. {
  48. if ($value !== '') $query->where('is_show', $value);
  49. }
  50. /**
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchIsDelAttr($query, $value)
  55. {
  56. if ($value !== '') $query->where('is_del', $value);
  57. }
  58. }