Files
animethemes-server/app/Http/Api/Schema/Wiki/ImageSchema.php
T
paranarimasu 295a997354 Api allowed pivots (#570)
* refactor(api): prefer including pivot types to conditional pivot information

* style: fix StyleCI findings
2023-04-14 18:36:29 -05:00

66 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Api\Schema\Wiki;
use App\Http\Api\Field\Field;
use App\Http\Api\Field\Wiki\Image\ImageFacetField;
use App\Http\Api\Field\Wiki\Image\ImageFileField;
use App\Http\Api\Field\Wiki\Image\ImageIdField;
use App\Http\Api\Field\Wiki\Image\ImageLinkField;
use App\Http\Api\Field\Wiki\Image\ImagePathField;
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\EloquentSchema;
use App\Http\Resources\Wiki\Resource\ImageResource;
use App\Models\Wiki\Image;
/**
* Class ImageSchema.
*/
class ImageSchema extends EloquentSchema
{
/**
* Get the type of the resource.
*
* @return string
*/
public function type(): string
{
return ImageResource::$wrap;
}
/**
* Get the allowed includes.
*
* @return AllowedInclude[]
*/
public function allowedIncludes(): array
{
return [
new AllowedInclude(new AnimeSchema(), Image::RELATION_ANIME),
new AllowedInclude(new ArtistSchema(), Image::RELATION_ARTISTS),
new AllowedInclude(new StudioSchema(), Image::RELATION_STUDIOS),
];
}
/**
* Get the direct fields of the resource.
*
* @return Field[]
*/
public function fields(): array
{
return array_merge(
parent::fields(),
[
new ImageIdField($this),
new ImageFacetField($this),
new ImagePathField($this),
new ImageLinkField($this),
new ImageFileField($this),
],
);
}
}