LiveroomController.php 842 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\index\controller;
  3. use think\exception\ValidateException;
  4. use app\model\LiveRoom;
  5. use app\model\LiveAnchor;
  6. class LiveroomController extends Base
  7. {
  8. public function index()
  9. {
  10. $weid = weid();
  11. $serach['keyword'] = input('post.keyword', '', 'serach_in');
  12. $query = LiveRoom::where(['weid' => $weid]);
  13. if (!empty($serach['keyword'])) {
  14. $query->where('name', 'like', '%' . $serach['keyword'] . '%');
  15. }
  16. $res = $query->paginate(getpage())->toArray();
  17. foreach ($res['data'] as &$vo) {
  18. $vo['share_img'] = toimg($vo['share_img']);
  19. $vo['anchor'] = LiveAnchor::getAnchor($vo['anchor_id']);
  20. $vo['start_time'] = time_format($vo['start_time']);
  21. }
  22. $data['data'] = $res;
  23. return $this->json($data);
  24. }
  25. }