rest_paginate( ChannelResource::collection( Channel::query() ->with('media') ->where('is_visible', true) ->ordered() ->simplePaginate( perPage: $request->perPage, columns: $request->fields, ) ) ); } /** * Channels (show) */ public function show(Channel $channel): JsonResponse { $channel->load('media'); return response()->rest(new ChannelResource($channel)); } /** * Channels (products) */ public function products(Request $request, Channel $channel): JsonResponse { return response()->rest_paginate( ProductResource::collection( ProductRepository::make($request) ->queryAsFromResource($channel) ->applyBasicQueries() ->applyFilters() ->applySorting() ->simplePaginate() ) ); } }