service = $service; } /** * GET /api/v1/artworks/{slug} * Returns a single public artwork resource by slug. */ public function show(string $slug) { $artwork = $this->service->getPublicArtworkBySlug($slug); // Return the artwork instance (service already loads lightweight relations). // Log resolved resource for debugging failing test assertions. // Return the resolved payload directly to avoid JsonResource wrapping inconsistencies return response()->json((new ArtworkResource($artwork))->resolve(), 200); } /** * GET /api/v1/categories/{slug}/artworks * Uses route-model binding for Category (slug). Returns paginated list resource. */ public function categoryArtworks(Request $request, Category $category) { $perPage = (int) $request->get('per_page', 24); $paginator = $this->service->getCategoryArtworks($category, $perPage); return ArtworkListResource::collection($paginator); } }