cambios menores
This commit is contained in:
parent
09a024b69d
commit
c746e41060
2 changed files with 13 additions and 15 deletions
|
@ -21,7 +21,7 @@ class BarrioSeeder extends Seeder
|
||||||
])->id;
|
])->id;
|
||||||
|
|
||||||
Barrio::create([
|
Barrio::create([
|
||||||
'name'=>'PRUEBA','region_id'=>$prueba_id, 'created_at'=>Date::now()
|
'name'=>'PRUEBA','region_id' => $prueba_id
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,16 +37,15 @@ class CanastaSeeder extends Seeder
|
||||||
$tipo = trim($record[$tipoColumn]);
|
$tipo = trim($record[$tipoColumn]);
|
||||||
|
|
||||||
if (!in_array($tipo, $tipos)) {
|
if (!in_array($tipo, $tipos)) {
|
||||||
if (!Str::contains($tipo,'¿') && ($tipo != 'T')) {
|
if (!Str::contains($tipo,'¿') && ($tipo != 'T'))
|
||||||
$currentCategoria = Categoria::firstOrCreate(['name' => $tipo]);
|
$currentCategoria = Categoria::firstOrCreate(['name' => $tipo]);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$parsed = $this->parseAndFormatName($record[$productoColumn]);
|
[$solidario, $name, $caracteristicas] = $this->parseAndFormatName($record[$productoColumn]);
|
||||||
|
|
||||||
$productosToInsert[] = [
|
$productosToInsert[] = [
|
||||||
'name' => $parsed['name'],
|
'name' => $name,
|
||||||
'price' => $record[$precioColumn],
|
'price' => $record[$precioColumn],
|
||||||
'solidario' => $parsed['solidario'],
|
'solidario' => $solidario,
|
||||||
'bono' => $tipo == 'B',
|
'bono' => $tipo == 'B',
|
||||||
'categoria_id' => $currentCategoria->id,
|
'categoria_id' => $currentCategoria->id,
|
||||||
'created_at' => Date::now(),
|
'created_at' => Date::now(),
|
||||||
|
@ -54,23 +53,22 @@ class CanastaSeeder extends Seeder
|
||||||
];
|
];
|
||||||
|
|
||||||
$caracteristicasToInsert[] = [
|
$caracteristicasToInsert[] = [
|
||||||
'name' => $parsed['name'],
|
'name' => $name,
|
||||||
'caracteristicas' => $parsed['caracteristicas']
|
'caracteristicas' => $caracteristicas
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_chunk($productosToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk) {
|
foreach (array_chunk($productosToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
|
||||||
DB::table('productos')->insert($chunk);
|
DB::table('productos')->insert($chunk);
|
||||||
}
|
|
||||||
|
|
||||||
$this->insertCaracteristicas($caracteristicasToInsert);
|
$this->insertCaracteristicas($caracteristicasToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array data parsed from productoColumn.
|
* Returns an array with data parsed from productoColumn.
|
||||||
*
|
*
|
||||||
* @return array{solidario: bool, name: string, caracteristicas: array(Caracteristica)}
|
* @return array{solidario: bool, name: string, caracteristicas: array(Caracteristica->id)}
|
||||||
*/
|
*/
|
||||||
private function parseAndFormatName($productoColumn): array {
|
private function parseAndFormatName($productoColumn): array {
|
||||||
$solidario = Str::contains($productoColumn, '*');
|
$solidario = Str::contains($productoColumn, '*');
|
||||||
|
@ -91,9 +89,9 @@ class CanastaSeeder extends Seeder
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'solidario' => $solidario,
|
$solidario,
|
||||||
'name' => trim($name),
|
trim($name),
|
||||||
'caracteristicas' => $caracteristicas
|
$caracteristicas
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue