Hueco para transporte

This commit is contained in:
Alejandro Tasistro 2024-12-09 20:58:56 -03:00
parent 9abeb98239
commit 8a0f8fbe13
1 changed files with 16 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use League\Csv\CannotInsertRecord; use League\Csv\CannotInsertRecord;
use League\Csv\Reader;
use League\Csv\Writer; use League\Csv\Writer;
class Producto extends Model class Producto extends Model
@ -91,10 +92,11 @@ class Producto extends Model
$cantidadesPorBarrio = self::cantidadesPorBarrio(); $cantidadesPorBarrio = self::cantidadesPorBarrio();
$planilla = []; $planilla = [];
$ultimaFila = 1; $ultimaFila = 1;
$filaTransporte = self::filaTransporte();
foreach ($cantidadesPorBarrio as $productoCantidades) { foreach ($cantidadesPorBarrio as $productoCantidades) {
$fila = $productoCantidades->fila; $fila = $productoCantidades->fila;
if ($fila - $ultimaFila > 1) { while ($fila - $ultimaFila > 1) {
$ultimaFila++; $ultimaFila++;
$planilla[$ultimaFila] = ['---']; $planilla[$ultimaFila] = ['---'];
} }
@ -157,4 +159,17 @@ class Producto extends Model
var_export($e->getRecords()); var_export($e->getRecords());
} }
} }
private static function filaTransporte()
{
$csv = Reader::createFromPath(resource_path('csv/productos.csv'), 'r');
$csv->setDelimiter("|");
$csv->setEnclosure("'");
$registros = $csv->getRecords();
foreach ($registros as $key => $registro)
if ($registro[0] == 'T') return $key;
throw new Exception('No hay bono de transporte');
}
} }