API changes
This commit is contained in:
@@ -16,8 +16,10 @@ final class RecentArticles extends Controller
|
||||
*/
|
||||
public function __invoke()
|
||||
{
|
||||
return Article::with('source', 'topics')
|
||||
->latest("published_date")
|
||||
->paginate(20);
|
||||
return [
|
||||
"articles" => Article::with('source', 'topics')
|
||||
->latest("published_date")
|
||||
->paginate(20)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user