海南旅游SAAS
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.

33 lines
791 B

  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Channel;
  5. use App\Models\UserChannel;
  6. /**
  7. * 频道列表
  8. * Class Channel
  9. * @package App\Http\Controllers\Api
  10. */
  11. class ChannelController extends Controller
  12. {
  13. // 所有频道列表
  14. public function index()
  15. {
  16. $list = Channel::query()
  17. ->where('agent_id', $this->agent_id)
  18. ->orderBy('sort')
  19. ->orderBy('id')
  20. ->get(['id', 'pid', 'name', 'icon']);
  21. return $this->success($list);
  22. }
  23. // 我的频道
  24. public function my()
  25. {
  26. $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels');
  27. $list = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']);
  28. return $this->success($list);
  29. }
  30. }