mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-08 05:33:12 +02:00
37 lines
922 B
PHP
37 lines
922 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Schema\Fields\Base\Aggregate;
|
|
|
|
use App\Contracts\GraphQL\Fields\DisplayableField;
|
|
use App\Enums\GraphQL\Field\AggregateFunction;
|
|
use App\Enums\GraphQL\Filter\Clause;
|
|
use App\GraphQL\Filter\BooleanFilter;
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
class ExistsField extends AggregateField implements DisplayableField
|
|
{
|
|
public function __construct(
|
|
protected string $aggregateRelation,
|
|
protected bool $nullable = false,
|
|
) {
|
|
parent::__construct($aggregateRelation, $aggregateRelation.'Exists', AggregateFunction::EXISTS, '*', $nullable);
|
|
}
|
|
|
|
public function baseType(): Type
|
|
{
|
|
return Type::boolean();
|
|
}
|
|
|
|
public function canBeDisplayed(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function getFilter(): BooleanFilter
|
|
{
|
|
return new BooleanFilter($this->name(), $this->alias(), Clause::HAVING);
|
|
}
|
|
}
|