mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
45 lines
907 B
PHP
45 lines
907 B
PHP
<?php
|
|
|
|
namespace App\Transformers;
|
|
|
|
use App\Models\TransactionDetail;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class TransactionDetailTransformer extends TransformerAbstract
|
|
{
|
|
/**
|
|
* List of resources to automatically include
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $defaultIncludes = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* List of resources possible to include
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $availableIncludes = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* A Fractal transformer.
|
|
*
|
|
* @param TransactionDetail $detail
|
|
* @return array
|
|
*/
|
|
public function transform(TransactionDetail $detail): array
|
|
{
|
|
return [
|
|
'reference' => $detail->reference,
|
|
'quantity' => $detail->quantity,
|
|
'price' => (double)$detail->price,
|
|
'name' => $detail->name,
|
|
'amount' => (double)$detail->amount
|
|
];
|
|
}
|
|
}
|