Created
June 3, 2018 23:58
-
-
Save stephenjude/6bfb035c3d02c118e1cadbbf793c61cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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