39 lines
1.3 KiB
PHP

<?php
namespace App\Http\Resources;
use App\Http\Resources\Product\ProductResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class StockMoveResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'product_id' => $this->product_id,
'from_warehouse_id' => $this->from_warehouse_id,
'to_warehouse_id' => $this->to_warehouse_id,
'packaging_id' => $this->packaging_id,
'packages_qty' => $this->packages_qty,
'units_qty' => $this->units_qty,
'qty_base' => $this->qty_base,
'move_type' => $this->move_type,
'ref_type' => $this->ref_type,
'ref_id' => $this->ref_id,
'moved_at' => $this->moved_at,
'product' => new ProductResource($this->whenLoaded('product')),
'from_warehouse' => new WarehouseResource($this->whenLoaded('fromWarehouse')),
'to_warehouse' => new WarehouseResource($this->whenLoaded('toWarehouse')),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}