setDelimiter("|"); $csv->setEnclosure("'"); $csv->setHeaderOffset(0); $registros = $csv->getRecords(); $gdcToInsert = []; $usersToInsert = []; foreach($registros as $key => $registro){ $gdcToInsert[] = [ 'nombre' => $registro['barrio'], 'region' => $registro['region'], 'telefono' => $registro['telefono'], 'correo' => $registro['correo'], 'referente_finanzas' => $registro['referente'] ]; $usersToInsert[] = [ 'name' => $registro['barrio'], 'password' => Hash::make($registro['barrio']), "is_admin" => 0, 'grupo_de_compra_id' => $key ]; $usersToInsert[] = [ 'name' => $registro['barrio'] . "_admin", 'password' => Hash::make($registro['barrio'] . "admin"), "is_admin" => 1, 'grupo_de_compra_id' => $key ]; } foreach (array_chunk($gdcToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk) { DB::table('grupos_de_compra')->insert($chunk); } foreach (array_chunk($usersToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk) { DB::table('users')->insert($chunk); } } }