<?php

namespace App\Service\Tms;
use App\Models\Tms\TmsRequestionItem;
use App\Models\Tms\TmsRequestion;
use Log;
use Auth;
use Carbon\Carbon;

class TmsRequestionService
{
    public function materialRequestionItem($request,$requisition_item){

        if(isset($request['request_items'])){

            foreach ($request['request_items'] as $key => $requisition) {

                $data=[
                    'item_id','item_name', 'quantity','notes','unit_id'
                ];
                
                foreach ($data as $key => $value) {
                    if(isset($requisition[$value]) && $requisition[$value]!=null && $requisition[$value]!=''){
                        $obj[$value]=$requisition[$value];
                    }
                }
                
                $obj['requestion_id'] = $requisition_item['id'];

                $requisitionItem=TmsRequestionItem::create($obj);

            }
        
            return true;
        }
    }


}