mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-20 04:53:56 +00:00
37 lines
1008 B
PHP
37 lines
1008 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TransactionDetailResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$item_from_1688 = str_contains($this->product_code, 'offerId');
|
|
$offer_id_1688 = null;
|
|
if ($item_from_1688) {
|
|
$offerId = explode(',', $this->product_code)[0];
|
|
$offer_id_1688 = substr($offerId, strpos($offerId, ':') + 1);
|
|
}
|
|
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'stockCode' => $this->product_code,
|
|
'description' => $this->product_name,
|
|
'quantity' => $this->quantity,
|
|
'unit_price' => (double) $this->price,
|
|
'total' => (double) $this->amount,
|
|
'item_from_1688' => $item_from_1688,
|
|
'offer_id_1688' => $offer_id_1688
|
|
];
|
|
}
|
|
}
|