mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
- anime schedules - validation and corrections - refactorings around "augmentResponse" - macro usage instead
34 lines
806 B
PHP
34 lines
806 B
PHP
<?php
|
|
|
|
namespace App\Features;
|
|
|
|
use App\Contracts\CharacterRepository;
|
|
use App\Dto\QueryRandomCharacterCommand;
|
|
use App\Http\Resources\V4\CharacterResource;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* @extends QueryRandomItemHandler<QueryRandomCharacterCommand, CharacterResource>
|
|
*/
|
|
final class QueryRandomCharacterHandler extends QueryRandomItemHandler
|
|
{
|
|
public function __construct(CharacterRepository $repository)
|
|
{
|
|
parent::__construct($repository);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function requestClass(): string
|
|
{
|
|
return QueryRandomCharacterCommand::class;
|
|
}
|
|
|
|
protected function resource(Collection $results): JsonResource
|
|
{
|
|
return new CharacterResource($results->first());
|
|
}
|
|
}
|