From 73752f90deecba629e58510e112bbaf1bffb66de Mon Sep 17 00:00:00 2001 From: ale Date: Wed, 3 Jul 2024 19:46:48 -0300 Subject: [PATCH] Ajustes de traduccion y creacion post merge --- database/seeders/BonoBarrialSeeder.php | 4 ++-- database/seeders/CanastaSeeder.php | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/database/seeders/BonoBarrialSeeder.php b/database/seeders/BonoBarrialSeeder.php index 425de35..359b05a 100644 --- a/database/seeders/BonoBarrialSeeder.php +++ b/database/seeders/BonoBarrialSeeder.php @@ -23,10 +23,10 @@ public function run(): void 'precio' => 20, 'solidario' => false, 'bono' => true, - 'categoria_id' => Categoria::first([ + 'categoria_id' => Categoria::firstOrCreate([ 'nombre' => 'TRANSPORTE, BONOS Y FINANCIAMIENTO SORORO' ])->id, - 'barrio_id' => Barrio::first([ + 'barrio_id' => Barrio::firstOrCreate([ 'nombre'=>'PRUEBA' ])->id, ]); diff --git a/database/seeders/CanastaSeeder.php b/database/seeders/CanastaSeeder.php index 6ddec86..0bb11a9 100644 --- a/database/seeders/CanastaSeeder.php +++ b/database/seeders/CanastaSeeder.php @@ -41,12 +41,12 @@ public function run(): void $currentCategoria = Categoria::firstOrCreate(['nombre' => $tipo]); } } else { - [$solidario, $name, $caracteristicas] = $this->parseAndFormatName($record[$productoColumn]); + [$solidario, $nombre, $caracteristicas] = $this->parseAndFormatName($record[$productoColumn]); $productosToInsert[] = [ - 'nombre' => $parsed['nombre'], + 'nombre' => $nombre, 'precio' => $record[$precioColumn], - 'solidario' => $parsed['solidario'], + 'solidario' => $solidario, 'bono' => $tipo == 'B', 'categoria_id' => $currentCategoria->id, 'created_at' => Date::now(), @@ -54,8 +54,8 @@ public function run(): void ]; $caracteristicasToInsert[] = [ - 'nombre' => $parsed['nombre'], - 'caracteristicas' => $parsed['caracteristicas'] + 'nombre' => $nombre, + 'caracteristicas' => $caracteristicas ]; } } @@ -89,11 +89,7 @@ private function parseAndFormatName($productoColumn): array { $nombre = Str::replaceMatches('/\(S\-.*\)/', '', $nombre); } - return [ - 'solidario' => $solidario, - 'nombre' => trim($nombre), - 'caracteristicas' => $caracteristicas - ]; + return [$solidario, trim($nombre), $caracteristicas]; } private function insertCaracteristicas($caracteristicasToInsert) : void { @@ -102,7 +98,7 @@ private function insertCaracteristicas($caracteristicasToInsert) : void { $match = Producto::where('nombre',$nombre)->first(); if ($match) { foreach ($item['caracteristicas'] as $codigo => $caracteristica) { - DB::table('productos_caracteristicas')->insert([ + DB::table('producto_caracteristica')->insert([ 'producto_id' => $match->id, 'caracteristica_id' => $caracteristica, ]);