setDelimiter("|"); $csv->setEnclosure("'"); $csv->setHeaderOffset(0); $registros = $csv->getRecords(); $gdcToInsert = []; $usersToInsert = []; foreach($registros as $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']) ]; } 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); } } }