55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\JsonApi\Chapters;
|
|
|
|
use Neomerx\JsonApi\Schema\SchemaProvider;
|
|
|
|
class Schema extends SchemaProvider
|
|
{
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $resourceType = 'chapters';
|
|
|
|
/**
|
|
* @param \App\Chapter $resource
|
|
* the domain record being serialized.
|
|
* @return string
|
|
*/
|
|
public function getId($resource)
|
|
{
|
|
return (string) $resource->getRouteKey();
|
|
}
|
|
|
|
/**
|
|
* @param \App\Chapter $resource
|
|
* the domain record being serialized.
|
|
* @return array
|
|
*/
|
|
public function getAttributes($resource)
|
|
{
|
|
return [
|
|
'name' => $resource->name,
|
|
'created-at' => $resource->created_at->toAtomString(),
|
|
'updated-at' => $resource->updated_at->toAtomString(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param object $resource
|
|
* @param bool $isPrimary
|
|
* @param array $includeRelationships
|
|
* @return array|\bool[][]
|
|
*/
|
|
public function getRelationships($resource, $isPrimary, array $includeRelationships)
|
|
{
|
|
return [
|
|
'verses' => [
|
|
self::SHOW_SELF => true,
|
|
self::SHOW_RELATED => true,
|
|
]
|
|
];
|
|
}
|
|
}
|