validated(); $perPage = $validatedData['per_page'] ?? 15; $page = $validatedData['page'] ?? 1; $books = Book::where('volum_id', $validated['volum_id'])->paginate($perPage, ['*'], 'page', $page); $books->getCollection()->transform(function ($section) { $section['is_locked'] = auth()->user()->isSubscriber() !== true ? true : Law::where('is_locked',$section['law_id'])->first()?->is_locked ?? false; unset($section['law_id']); unset($section['volum_id']); return $section; }); return $this->success($books->items(), 'Success'); } }