mirror of https://github.com/kcal-app/kcal.git
				
				
				
			
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App\JsonApi\Schemas;
 | |
| 
 | |
| use Neomerx\JsonApi\Schema\SchemaProvider;
 | |
| 
 | |
| class RecipeSeparatorSchema extends SchemaProvider
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     protected $resourceType = 'recipe-separators';
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     public function getId($resource): string
 | |
|     {
 | |
|         return (string) $resource->getRouteKey();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     public function getAttributes($resource): array
 | |
|     {
 | |
|         /** @var \App\Models\RecipeSeparator $resource */
 | |
|         return [
 | |
|             'container' => $resource->container,
 | |
|             'weight' => $resource->weight,
 | |
|             'text' => $resource->text,
 | |
|             '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,
 | |
|             ]
 | |
|         ];
 | |
|     }
 | |
| }
 |