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
36 lines
792 B
PHP
36 lines
792 B
PHP
<?php
|
|
|
|
namespace App\Features;
|
|
|
|
use App\Contracts\UserRepository;
|
|
use App\Dto\QueryRandomUserCommand;
|
|
use App\Http\Resources\V4\ProfileResource;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* @extends QueryRandomItemHandler<QueryRandomUserCommand, ProfileResource>
|
|
*/
|
|
final class QueryRandomUserHandler extends QueryRandomItemHandler
|
|
{
|
|
public function __construct(UserRepository $repository)
|
|
{
|
|
parent::__construct($repository);
|
|
}
|
|
|
|
protected function resource(Collection $results): JsonResource
|
|
{
|
|
return new ProfileResource(
|
|
$results->first()
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function requestClass(): string
|
|
{
|
|
return QueryRandomUserCommand::class;
|
|
}
|
|
}
|