LiveAnchor.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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. * 主播
  17. * Class LiveAnchor
  18. * @package app\model\activity\live
  19. */
  20. class LiveAnchor extends BaseModel
  21. {
  22. use ModelTrait;
  23. protected $pk = 'id';
  24. protected $name = 'live_anchor';
  25. protected $autoWriteTimestamp = 'int';
  26. protected $createTime = 'add_time';
  27. protected function setAddTimeAttr()
  28. {
  29. return time();
  30. }
  31. /**
  32. * 添加时间获取器
  33. * @param $value
  34. * @return false|string
  35. */
  36. public function getAddTimeAttr($value)
  37. {
  38. if (!empty($value)) {
  39. return date('Y-m-d H:i:s', (int)$value);
  40. }
  41. return '';
  42. }
  43. public function room()
  44. {
  45. return $this->hasOne(LiveRoom::class, 'anchor_wechat', 'wechat');
  46. }
  47. public function searchKerwordAttr($query, $value)
  48. {
  49. if ($value !== '') $query->whereLike('id|name|wechat|phone', "%{$value}%");
  50. }
  51. /**
  52. * @param Model $query
  53. * @param $value
  54. */
  55. public function searchIsShowAttr($query, $value)
  56. {
  57. if ($value !== '') $query->where('is_show', $value);
  58. }
  59. /**
  60. * @param Model $query
  61. * @param $value
  62. */
  63. public function searchIsDelAttr($query, $value)
  64. {
  65. if ($value !== '') $query->where('is_del', $value);
  66. }
  67. }