<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PurchaseItem extends Model
{
    protected $table = 'purchase_items'; 
    protected $fillable = [
        'grn_no', 'qty', 'initial_cost', 'vat_amount', 'sscl_amount', 'final_cost',
        'sales_price', 'margin_amount', 'margin_percentage', 'market_price', 
        'total_cost', 'free_item', 'item_id'
    ];

    public function purchase()
    {
        return $this->belongsTo(Purchase::class, 'grn_no', 'grn_no');
    }

    public function item()
    {
        return $this->belongsTo(items::class);
    }
}