Files
animethemes-server/app/Http/Api/Schema/Wiki/Video/ScriptSchema.php
T
paranarimasu 128b90dae2 refactor(api): provide query to field to determine selection and aggregation (#512)
* refactor(api): provide query to field to determine selection and aggregation

* style: fix StyleCI findings
2023-02-01 23:31:55 -06:00

73 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Api\Schema\Wiki\Video;
use App\Http\Api\Field\Base\IdField;
use App\Http\Api\Field\Field;
use App\Http\Api\Field\Wiki\Video\Script\ScriptLinkField;
use App\Http\Api\Field\Wiki\Video\Script\ScriptPathField;
use App\Http\Api\Field\Wiki\Video\Script\ScriptVideoIdField;
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\EloquentSchema;
use App\Http\Api\Schema\Wiki\VideoSchema;
use App\Http\Resources\Wiki\Video\Resource\ScriptResource;
use App\Models\Wiki\Video\VideoScript;
/**
* Class ScriptSchema.
*/
class ScriptSchema extends EloquentSchema
{
/**
* The model this schema represents.
*
* @return string
*/
public function model(): string
{
return VideoScript::class;
}
/**
* Get the type of the resource.
*
* @return string
*/
public function type(): string
{
return ScriptResource::$wrap;
}
/**
* Get the allowed includes.
*
* @return AllowedInclude[]
*/
public function allowedIncludes(): array
{
return [
new AllowedInclude(new VideoSchema(), VideoScript::RELATION_VIDEO),
];
}
/**
* Get the direct fields of the resource.
*
* @return Field[]
*/
public function fields(): array
{
return array_merge(
parent::fields(),
[
new IdField($this, VideoScript::ATTRIBUTE_ID),
new ScriptPathField($this),
new ScriptLinkField($this),
new ScriptVideoIdField($this),
],
);
}
}