json); $tableName = "m_t_o_s"; $mtos = db($tableName); $mtos = $mtos->groupBy("line") //->where("line","NI-80-AH01JL-FA00.830") ->get(); $prefix = "📂 line-specification"; Log::debug("$prefix start " . simdi()); $k = 0; foreach($mtos AS $mto) { $tableRows1 = ""; $tableRows2 = ""; $tableRows3 = ""; $fileName = $mto->line; $string = $documentInfo->html; $string = pdf_html_content($string); $string .= ""; $c1 = $mto->line; $c2 = ""; $string = str_replace("{c1}", $c1, $string); $string = str_replace("{c2}", $c2, $string); $pipes = db($tableName) ->where("line", $mto->line) ->where(function($query) use($tableName) { $types = ['PIPE']; foreach($types AS $type) { $query->orWhere("$tableName.longdescription", "like", "%$type%"); } $types = ['ТРУБА']; foreach($types AS $type) { $query->orWhere("$tableName.description_ru", "like", "%$type%"); } }) ->get(); $others = db($tableName) ->where("line", $mto->line) ->where(function($query) { $types = ['flange', 'elbow', 'Tee', 'reducer']; foreach($types AS $type) { $query->orWhere("longdescription", "like", "%$type%"); } }) ->get(); $others2 = db($tableName) ->where("line", $mto->line) ->where(function($query) { $types = ['support', 'gasket', 'nuts', 'bolt']; foreach($types AS $type) { $query->orWhere("longdescription", "like", "%$type%"); } }) ->get(); foreach($pipes AS $pipe) { $weldLog = db("weld_logs") ->where("line_number", $pipe->line) ->where("element_code_1", $pipe->component_code_id) ->first(); $tableRow1 = "