<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class SalesOrderItemResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [

            'id' => $this->id,

            'product_id' => $this->product_id,

            'product_name' => $this->product?->product_name,

            'product_code' => $this->product?->product_code,
            
            'stock' => $this->product?->stock_quantity,

            'quantity' => $this->quantity,

            'unit_price' => $this->unit_price,

            'discount' => $this->discount,

            'total' => $this->total

        ];
    }
}