input('view')) { case 'channel': $table = ProgressChapter::select($select) ->whereIn('progress_chapters.channel_id', explode('_', $request->input('channels', ''))); break; default: throw ValidationException::withMessages(['view' => __('site.invalid_parameter')]); break; } if ($request->filled('level')) { $table = $table->join('pali_texts', function ($join) { $join->on('progress_chapters.book', '=', 'pali_texts.book') ->on('progress_chapters.para', '=', 'pali_texts.paragraph'); })->where('pali_texts.level', '<=', (int) $request->input('level')); } if ($request->has('lang')) { $table = $table->where('progress_chapters.lang', $request->input('lang')); } if ($request->has('book')) { $table = $table->where('progress_chapters.book', $request->input('book')); } $table = $table->orderBy( 'progress_chapters.'.$request->input('order', 'completed_at'), $request->input('dir', 'desc') ); // 分页与 meta 全由框架算;page 参数 paginate() 自己会读 return ProgressV3Resource::collection( $table->paginate($request->integer('per_page', 10)) ); } /** * Store a newly created resource in storage. */ public function store(Request $request) { // } /** * Display the specified resource. */ public function show(string $id) { // } /** * Update the specified resource in storage. */ public function update(Request $request, string $id) { // } /** * Remove the specified resource from storage. */ public function destroy(string $id) { // } }