latest('id') ->paginate(12); return response()->json([ 'data' => ArticleResource::collection($articles), 'meta' => [ 'current_page' => $articles->currentPage(), 'last_page' => $articles->lastPage(), 'per_page' => $articles->perPage(), 'total' => $articles->total(), ], ]); } public function show(string $slug): JsonResponse { $article = WebsiteArticle::with(['user:id,username,look', 'comments.user:id,username,look']) ->where('slug', $slug) ->firstOrFail(); return response()->json(['data' => new ArticleResource($article)]); } }