API changes

This commit is contained in:
2020-08-22 12:50:50 +05:00
parent 2c319c3305
commit 0ca2d776d5
6 changed files with 15 additions and 11 deletions

View File

@@ -26,13 +26,12 @@ class TopicsAPIController extends Controller
* Load all the articles for a given topics
*
* @param mixed $topic
* @return JsonResponse
*/
public function show(Topic $topic) : JsonResponse
public function show(Topic $topic)
{
return response()->json([
return [
'topic' => new TopicResource($topic),
'articles' => ArticleResource::collection($topic->articles()->paginate(8))
]);
'articles' => $topic->articles()->paginate(8)
];
}
}