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

29 lines
738 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::orderBy('sort')->orderBy('id', 'DESC')->get(['id', 'pid', 'name', 'icon']);
  17. return $this->success($list);
  18. }
  19. // 我的频道
  20. public function my()
  21. {
  22. $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels');
  23. $list = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']);
  24. return $this->success($list);
  25. }
  26. }