mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
- improved searching with low letter count - removed the ability to order anime by type and rating - fixed schedules endpoint's filter parameter yet again - improved configuration - fixed filtering anime by producers - fixed filtering manga by magazines - fixed search analytics in case of short search terms
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Features;
|
|
|
|
use App\Contracts\AnimeRepository;
|
|
use App\Contracts\RequestHandler;
|
|
use App\Dto\QueryAnimeSchedulesCommand;
|
|
use App\Http\Resources\V4\AnimeCollection;
|
|
use App\Support\CachedData;
|
|
use Illuminate\Support\Env;
|
|
|
|
/**
|
|
* @implements RequestHandler<QueryAnimeSchedulesCommand, AnimeCollection>
|
|
*/
|
|
final class QueryAnimeSchedulesHandler implements RequestHandler
|
|
{
|
|
public function __construct(private readonly AnimeRepository $repository)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function handle($request)
|
|
{
|
|
$requestParams = collect($request->all());
|
|
$limit = $requestParams->get("limit");
|
|
$results = $this->repository->getCurrentlyAiring($request->filter);
|
|
// apply sfw, kids and unapproved filters
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
$results = $results->filter($requestParams);
|
|
$results = $results->paginate(
|
|
$limit,
|
|
["*"],
|
|
null,
|
|
$request->page
|
|
);
|
|
|
|
$animeCollection = new AnimeCollection(
|
|
$results
|
|
);
|
|
$response = $animeCollection->response();
|
|
|
|
return $response->addJikanCacheFlags($request->getFingerPrint(), CachedData::from($animeCollection->collection));
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function requestClass(): string
|
|
{
|
|
return QueryAnimeSchedulesCommand::class;
|
|
}
|
|
}
|