mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
add support for filtering anime/manga forum topics
This commit is contained in:
parent
55f68046b2
commit
41482625de
@ -42,9 +42,13 @@ class AnimeController extends Controller
|
||||
return response($this->serializer->serialize($anime, 'json'));
|
||||
}
|
||||
|
||||
public function forum(int $id)
|
||||
public function forum(int $id, ?string $topic = null)
|
||||
{
|
||||
$anime = ['topics' => $this->jikan->getAnimeForum(new AnimeForumRequest($id))];
|
||||
if ($topic === 'episodes') {
|
||||
$topic = 'episode';
|
||||
}
|
||||
|
||||
$anime = ['topics' => $this->jikan->getAnimeForum(new AnimeForumRequest($id, $topic))];
|
||||
return response($this->serializer->serialize($anime, 'json'));
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,14 @@ class MangaController extends Controller
|
||||
return response($this->serializer->serialize($manga, 'json'));
|
||||
}
|
||||
|
||||
public function forum(int $id)
|
||||
public function forum(int $id, ?string $topic = null)
|
||||
{
|
||||
$manga = ['topics' => $this->jikan->getMangaForum(new MangaForumRequest($id))];
|
||||
// safely bypass MAL's naming schemes
|
||||
if ($topic === 'chapters') {
|
||||
$topic = 'episode';
|
||||
}
|
||||
|
||||
$manga = ['topics' => $this->jikan->getMangaForum(new MangaForumRequest($id, $topic))];
|
||||
return response($this->serializer->serialize($manga, 'json'));
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ $router->group(
|
||||
'uses' => 'AnimeController@news'
|
||||
]);
|
||||
|
||||
$router->get('/forum', [
|
||||
$router->get('/forum[/{topic:[A-Za-z]+}]', [
|
||||
'uses' => 'AnimeController@forum'
|
||||
]);
|
||||
|
||||
@ -111,7 +111,7 @@ $router->group(
|
||||
'uses' => 'MangaController@news'
|
||||
]);
|
||||
|
||||
$router->get('/forum', [
|
||||
$router->get('/forum[/{topic:[A-Za-z]+}]', [
|
||||
'uses' => 'MangaController@forum'
|
||||
]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user