kcal/app/JsonApi/Schemas/UserSchema.php

36 lines
659 B
PHP

<?php
namespace App\JsonApi\Schemas;
use Neomerx\JsonApi\Schema\SchemaProvider;
class UserSchema extends SchemaProvider
{
/**
* {@inheritdoc}
*/
protected $resourceType = 'users';
/**
* {@inheritdoc}
*/
public function getId($resource): string
{
return (string) $resource->getRouteKey();
}
/**
* {@inheritdoc}
*/
public function getAttributes($resource): array
{
return [
'name' => $resource->name,
'email' => $resource->email,
'createdAt' => $resource->created_at,
'updatedAt' => $resource->updated_at,
];
}
}