mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-11-13 09:38:48 +01:00
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Api\Schema\Document;
|
|
|
|
use App\Http\Api\Field\Base\IdField;
|
|
use App\Http\Api\Field\Document\Page\PageBodyField;
|
|
use App\Http\Api\Field\Document\Page\PageNameField;
|
|
use App\Http\Api\Field\Document\Page\PageNextIdField;
|
|
use App\Http\Api\Field\Document\Page\PagePreviousIdField;
|
|
use App\Http\Api\Field\Document\Page\PageSlugField;
|
|
use App\Http\Api\Field\Field;
|
|
use App\Http\Api\Include\AllowedInclude;
|
|
use App\Http\Api\Schema\EloquentSchema;
|
|
use App\Http\Resources\Document\Resource\PageJsonResource;
|
|
use App\Models\Document\Page;
|
|
|
|
class PageSchema extends EloquentSchema
|
|
{
|
|
public function type(): string
|
|
{
|
|
return PageJsonResource::$wrap;
|
|
}
|
|
|
|
/**
|
|
* @return AllowedInclude[]
|
|
*/
|
|
public function allowedIncludes(): array
|
|
{
|
|
return $this->withIntermediatePaths([
|
|
new AllowedInclude(new PageSchema(), Page::RELATION_NEXT),
|
|
new AllowedInclude(new PageSchema(), Page::RELATION_PREVIOUS),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return Field[]
|
|
*/
|
|
public function fields(): array
|
|
{
|
|
return array_merge(
|
|
parent::fields(),
|
|
[
|
|
new IdField($this, Page::ATTRIBUTE_ID),
|
|
new PageNameField($this),
|
|
new PageSlugField($this),
|
|
new PageBodyField($this),
|
|
new PageNextIdField($this),
|
|
new PagePreviousIdField($this),
|
|
],
|
|
);
|
|
}
|
|
}
|