LiveAnchor.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\activity\live;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * Class LiveAnchor
  17. * @package app\model\live
  18. */
  19. class LiveAnchor extends BaseModel
  20. {
  21. use ModelTrait;
  22. protected $pk = 'id';
  23. protected $name = 'live_anchor';
  24. protected $autoWriteTimestamp = 'int';
  25. protected $createTime = 'add_time';
  26. protected function setAddTimeAttr()
  27. {
  28. return time();
  29. }
  30. /**
  31. * 添加时间获取器
  32. * @param $value
  33. * @return false|string
  34. */
  35. public function getAddTimeAttr($value)
  36. {
  37. if (!empty($value)) {
  38. return date('Y-m-d H:i:s', (int)$value);
  39. }
  40. return '';
  41. }
  42. public function room()
  43. {
  44. return $this->hasOne(LiveRoom::class, 'anchor_wechat', 'wechat');
  45. }
  46. public function searchKerwordAttr($query, $value)
  47. {
  48. if ($value !== '') $query->whereLike('id|name|wechat|phone', "%{$value}%");
  49. }
  50. /**
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchIsShowAttr($query, $value)
  55. {
  56. if ($value !== '') $query->where('is_show', $value);
  57. }
  58. /**
  59. * @param Model $query
  60. * @param $value
  61. */
  62. public function searchIsDelAttr($query, $value)
  63. {
  64. if ($value !== '') $query->where('is_del', $value);
  65. }
  66. }