kcal/app/JsonApi/Schemas/RecipeStepSchema.php

50 lines
1.0 KiB
PHP

<?php
namespace App\JsonApi\Schemas;
use CloudCreativity\LaravelJsonApi\Schema\SchemaProvider;
class RecipeStepSchema extends SchemaProvider
{
/**
* {@inheritdoc}
*/
protected string $resourceType = 'recipe-steps';
/**
* {@inheritdoc}
*/
public function getId($resource): string
{
return (string) $resource->getRouteKey();
}
/**
* {@inheritdoc}
*/
public function getAttributes($resource): array
{
/** @var \App\Models\RecipeStep $resource */
return [
'number' => $resource->number,
'step' => $resource->step,
'createdAt' => $resource->created_at,
'updatedAt' => $resource->updated_at,
];
}
/**
* @inheritdoc
*/
public function getRelationships($resource, $isPrimary, array $includeRelationships): array
{
return [
'recipe' => [
self::SHOW_SELF => true,
self::SHOW_RELATED => true,
]
];
}
}