mirror of https://github.com/kcal-app/kcal.git
40 lines
821 B
PHP
40 lines
821 B
PHP
<?php
|
|
|
|
namespace App\JsonApi\Schemas;
|
|
|
|
use Neomerx\JsonApi\Schema\SchemaProvider;
|
|
|
|
class UserSchema extends SchemaProvider
|
|
{
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $resourceType = 'users';
|
|
|
|
/**
|
|
* @param \App\Models\User $resource
|
|
* the domain record being serialized.
|
|
* @return string
|
|
*/
|
|
public function getId($resource)
|
|
{
|
|
return (string) $resource->getRouteKey();
|
|
}
|
|
|
|
/**
|
|
* @param \App\Models\User $resource
|
|
* the domain record being serialized.
|
|
* @return array
|
|
*/
|
|
public function getAttributes($resource)
|
|
{
|
|
return [
|
|
'name' => $resource->name,
|
|
'email' => $resource->email,
|
|
'createdAt' => $resource->created_at,
|
|
'updatedAt' => $resource->updated_at,
|
|
];
|
|
}
|
|
}
|