Guest User

Untitled

a guest
Oct 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\JsonApi\Food;
  4.  
  5. use Neomerx\JsonApi\Schema\SchemaProvider;
  6.  
  7. class Schema extends SchemaProvider
  8. {
  9.  
  10.     /**
  11.      * @var string
  12.      */
  13.     protected $resourceType = 'Food';
  14.  
  15.     /**
  16.      * @param $resource
  17.      *      the domain record being serialized.
  18.      * @return string
  19.      */
  20.     public function getId($resource)
  21.     {
  22.         return $resource->id;
  23.     }
  24.  
  25.     /**
  26.      * @param $resource
  27.      *      the domain record being serialized.
  28.      * @return array
  29.      */
  30.     public function getAttributes($resource)
  31.     {
  32.         // TODO
  33.         return [
  34.             'name' => $resource->name,
  35.             'min_price' => $resource->min_price,
  36.             'food_price' => $resource->food_price,
  37.             'market_product' => $resource->market_product
  38.         ];
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment