mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Schema\Fields\User\Like;
|
|
|
|
use App\Contracts\GraphQL\Fields\BindableField;
|
|
use App\Contracts\GraphQL\Fields\CreatableField;
|
|
use App\Contracts\GraphQL\Fields\DeletableField;
|
|
use App\GraphQL\Controllers\User\LikeController;
|
|
use App\GraphQL\Schema\Fields\Field;
|
|
use App\Models\List\Playlist;
|
|
use GraphQL\Type\Definition\Type;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Str;
|
|
|
|
class LikePlaylistField extends Field implements BindableField, CreatableField, DeletableField
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct('playlist');
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'The hashid of the playlist to like';
|
|
}
|
|
|
|
public function baseType(): Type
|
|
{
|
|
return Type::string();
|
|
}
|
|
|
|
/**
|
|
* The resolver to cast the model.
|
|
*/
|
|
public function bindResolver(array $args): Playlist
|
|
{
|
|
return Playlist::query()
|
|
->where(Playlist::ATTRIBUTE_HASHID, Arr::get($args, $this->getName()))
|
|
->firstOrFail();
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function getCreationRules(array $args): array
|
|
{
|
|
return [
|
|
Str::of('prohibits:')->append(LikeController::ATTRIBUTE_ENTRY)->__toString(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function getDeleteRules(array $args): array
|
|
{
|
|
return [
|
|
Str::of('prohibits:')->append(LikeController::ATTRIBUTE_ENTRY)->__toString(),
|
|
];
|
|
}
|
|
}
|