public function getCorrelativeReportNumber($abreviatura) { $reporte = ReportePAAC::getLastReporte($abreviatura)->first(); $string = ""; if ($reporte != null) { $numero = $reporte->numero_reporte_correlativo; $cantidad_digitos = strlen($numero + 1); for ($i = 0; $i < 4 - $cantidad_digitos; $i++) { $string = $string . "0"; } $string = $string . ($numero + 1); } else { $string = "0001"; } return $string; }