Skip to content

Instantly share code, notes, and snippets.

@stephenjude
Created June 3, 2018 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenjude/6bfb035c3d02c118e1cadbbf793c61cc to your computer and use it in GitHub Desktop.
Save stephenjude/6bfb035c3d02c118e1cadbbf793c61cc to your computer and use it in GitHub Desktop.
<?php
namespace App\Transformers;
use App\Product;
use League\Fractal;
class ProductTransformer extends Fractal\TransformerAbstract
{
public function transform(Product $product)
{
return [
'id' => (int) $product->id,
'product_name' => $product->product_name,
'product_description' => $product->product_description,
'created_at' => $product->created_at->format('d-m-Y'),
'updated_at' => $product->updated_at->format('d-m-Y'),
'links' => [
[
'uri' => 'products/'.$product->id,
]
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment