<?php

namespace App\Inventory;

use Illuminate\Database\Eloquent\Model;
use App\Inventory\Item;
use App\Inventory\BillOfQuantity;
use App\Inventory\PurchaseOrder;

class BOQItems extends Model
{
    public function massInsertBOQItem($object)
    {
        return \DB::transaction(function () use ($object)  {

            BOQItems::insert($object);
        });
    }


    public function getBOQItemById($id)
    {
        return BOQItems::where('bill_of_quantity_id', $id)->get();
    }

    public function item()
    {
        return $this->belongsTo(Item::class,'item_id')->withDefault();
    }

    public function boq()
    {
        return $this->belongsTo(BillOfQuantity::class,'bill_of_quantity_id')->withDefault();
    }

    public function po()
    {
        return $this->hasOne(PurchaseOrder::class,'b_o_q_item_id')->withDefault();
    }

}
