59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
namespace App\JsonApi\MorphLegends;
|
|
|
|
use Neomerx\JsonApi\Schema\SchemaProvider;
|
|
|
|
/**
|
|
* Schema.php
|
|
*
|
|
* @author: Leonard Smith <leonard@acornwebconsultants.com>
|
|
* Date: 4/11/21
|
|
* Time: 12:28 PM
|
|
*/
|
|
class Schema extends SchemaProvider
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $resourceType = 'morph-legends';
|
|
|
|
/**
|
|
* @param \App\MorphLegend $resource
|
|
* the domain record being serialized.
|
|
* @return string
|
|
*/
|
|
public function getId($resource)
|
|
{
|
|
return (string)$resource->getRouteKey();
|
|
}
|
|
|
|
/**
|
|
* @param \App\MorphLegend $resource
|
|
* the domain record being serialized.
|
|
* @return array
|
|
*/
|
|
public function getAttributes($resource)
|
|
{
|
|
return [
|
|
'morph' => $resource->morph,
|
|
'description' => $resource->description,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param object $resource
|
|
* @param bool $isPrimary
|
|
* @param array $includeRelationships
|
|
* @return array|\bool[][]
|
|
*/
|
|
public function getRelationships($resource, $isPrimary, array $includeRelationships)
|
|
{
|
|
return [
|
|
'words' => [
|
|
self::SHOW_SELF => true,
|
|
self::SHOW_RELATED => true,
|
|
]
|
|
];
|
|
}
|
|
}
|