New-Thanasoft/thanasoft-back/app/Http/Resources/GoodsReceiptLineResource.php

36 lines
1.2 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class GoodsReceiptLineResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'goods_receipt_id' => $this->goods_receipt_id,
'product_id' => $this->product_id,
'product' => new ProductResource($this->whenLoaded('product')),
'packaging_id' => $this->packaging_id,
'packaging' => new ProductPackagingResource($this->whenLoaded('packaging')),
'packages_qty_received' => $this->packages_qty_received,
'units_qty_received' => $this->units_qty_received,
'qty_received_base' => $this->qty_received_base,
'unit_price' => $this->unit_price,
'unit_price_per_package' => $this->unit_price_per_package,
'tva_rate_id' => $this->tva_rate_id,
'tva_rate' => new TvaRateResource($this->whenLoaded('tvaRate')),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}