diff --git a/app/Http/Controllers/TopicsController.php b/app/Http/Controllers/TopicsController.php new file mode 100644 index 0000000..ae32ae2 --- /dev/null +++ b/app/Http/Controllers/TopicsController.php @@ -0,0 +1,36 @@ +take(14)->get()); + } + + /** + * Load all the articles for a given topics + * + * @param mixed $topic + * @return JsonResponse + */ + public function show(Topic $topic) : JsonResponse + { + return response()->json([ + 'topic' => $topic, + 'articles' => $topic->articles()->paginate(8) + ]); + } +}