Files
animethemes-server/app/Http/Api/Schema/Auth/User/MySchema.php
T
ManiandGitHub 5100f13dd8 feat: Added permission for revalidating pages (#654)
* Added permissions as allowed include path.
* Added tracks and playlists as allowed include paths to videos
2024-04-16 17:52:53 +02:00

70 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Api\Schema\Auth\User;
use App\Http\Api\Field\Auth\User\UserEmailField;
use App\Http\Api\Field\Auth\User\UserEmailVerifiedAtField;
use App\Http\Api\Field\Auth\User\UserNameField;
use App\Http\Api\Field\Auth\User\UserTwoFactorConfirmedAtField;
use App\Http\Api\Field\Base\IdField;
use App\Http\Api\Field\Field;
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Auth\PermissionSchema;
use App\Http\Api\Schema\Auth\RoleSchema;
use App\Http\Api\Schema\EloquentSchema;
use App\Http\Api\Schema\List\PlaylistSchema;
use App\Http\Resources\Auth\User\Resource\MyResource;
use App\Models\Auth\User;
/**
* Class MySchema.
*/
class MySchema extends EloquentSchema
{
/**
* Get the type of the resource.
*
* @return string
*/
public function type(): string
{
return MyResource::$wrap;
}
/**
* Get the allowed includes.
*
* @return AllowedInclude[]
*/
public function allowedIncludes(): array
{
return [
new AllowedInclude(new PermissionSchema(), User::RELATION_PERMISSIONS),
new AllowedInclude(new PlaylistSchema(), User::RELATION_PLAYLISTS),
new AllowedInclude(new RoleSchema(), User::RELATION_ROLES),
new AllowedInclude(new PermissionSchema(), User::RELATION_ROLES_PERMISSIONS),
];
}
/**
* Get the direct fields of the resource.
*
* @return Field[]
*/
public function fields(): array
{
return array_merge(
parent::fields(),
[
new IdField($this, User::ATTRIBUTE_ID),
new UserNameField($this),
new UserEmailField($this),
new UserEmailVerifiedAtField($this),
new UserTwoFactorConfirmedAtField($this),
],
);
}
}