mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Schema\Fields\Wiki\Video;
|
|
|
|
use App\Contracts\GraphQL\Fields\CreatableField;
|
|
use App\Contracts\GraphQL\Fields\RequiredOnCreation;
|
|
use App\Contracts\GraphQL\Fields\UpdatableField;
|
|
use App\Enums\Models\Wiki\VideoSource;
|
|
use App\GraphQL\Filter\EnumFilter;
|
|
use App\GraphQL\Schema\Fields\EnumField;
|
|
use App\Models\Wiki\Video;
|
|
use Illuminate\Validation\Rules\Enum;
|
|
|
|
class VideoSourceField extends EnumField implements CreatableField, RequiredOnCreation, UpdatableField
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(Video::ATTRIBUTE_SOURCE, VideoSource::class);
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Where did this video come from?';
|
|
}
|
|
|
|
public function getFilter(): EnumFilter
|
|
{
|
|
return new EnumFilter($this->name(), $this->enum, $this->getColumn())
|
|
->useEq();
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function getCreationRules(array $args): array
|
|
{
|
|
return [
|
|
'required',
|
|
new Enum(VideoSource::class),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function getUpdateRules(array $args): array
|
|
{
|
|
return [
|
|
'sometimes',
|
|
'required',
|
|
new Enum(VideoSource::class),
|
|
];
|
|
}
|
|
}
|