@php
use Illuminate\Support\Facades\DB;
if($oldHD != '')
{
$type = $oldHD->XVPdtType;
}
else {
$type ='1';
}
$MasterItems = DB::table('tmstmproduct');
if(isset($WhereType) && isset($ValueWhere) && isset($operator)){
$MasterItems->where($WhereType,$operator,$ValueWhere);
}
if(isset($FullJoin) && $FullJoin == true){
$MasterItems = $MasterItems
->join("tmseason","tmstmproduct.XISeasonCode",".tmseason.XISeasonCode")
->join("tmforuse","tmstmproduct.XIForCode",".tmforuse.XIForCode")
->join("tmgenerate","tmstmproduct.XIGenerateCode",".tmgenerate.XIGenerateCode")
->join("tmshape","tmstmproduct.XIShapeCode",".tmshape.XIShapeCode")
->join("tmstmmaterial","tmstmproduct.xvmatcode",".tmstmmaterial.xvmatcode");
}
$MasterItems = $MasterItems->orderBy('xvpdtcode','desc')->get()->toArray();
foreach ($MasterItems as $item){
$item->size = DB::table('tmstmproductsize')
->where('xvpdtcode','=',$item->xvpdtcode)
->get()->toArray();
$item->mat2 = DB::table('tmstmmaterial')->where('xvmatcode','=',$item->XVMatCode2)->first();
}
@endphp