mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-20 19:38:02 +02:00
40 lines
769 B
PHP
40 lines
769 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Support\Relations;
|
|
|
|
use App\Enums\GraphQL\PaginationType;
|
|
use GraphQL\Type\Definition\Type;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class HasOneRelation extends Relation
|
|
{
|
|
public function type(): Type
|
|
{
|
|
if (! $this->nullable) {
|
|
return Type::nonNull($this->type);
|
|
}
|
|
|
|
return $this->type;
|
|
}
|
|
|
|
/**
|
|
* The pagination type if applicable.
|
|
*/
|
|
public function paginationType(): PaginationType
|
|
{
|
|
return PaginationType::NONE;
|
|
}
|
|
|
|
/**
|
|
* Resolve the relation.
|
|
*
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function resolve(Model $root, array $args): mixed
|
|
{
|
|
return $root->{$this->relationName};
|
|
}
|
|
}
|