Files
animethemes-server/app/Http/Api/Schema/Auth/UserSchema.php
T

58 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Api\Schema\Auth;
use App\Http\Api\Field\Auth\User\UserIdField;
use App\Http\Api\Field\Auth\User\UserNameField;
use App\Http\Api\Field\Field;
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\EloquentSchema;
use App\Http\Api\Schema\List\PlaylistSchema;
use App\Http\Resources\Auth\Resource\UserResource;
use App\Models\Auth\User;
/**
* Class UserSchema.
*/
class UserSchema extends EloquentSchema
{
/**
* Get the type of the resource.
*
* @return string
*/
public function type(): string
{
return UserResource::$wrap;
}
/**
* Get the allowed includes.
*
* @return AllowedInclude[]
*/
public function allowedIncludes(): array
{
return [
new AllowedInclude(new PlaylistSchema(), User::RELATION_PLAYLISTS),
];
}
/**
* Get the direct fields of the resource.
*
* @return Field[]
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public function fields(): array
{
return [
new UserIdField($this),
new UserNameField($this),
];
}
}