Loading app/Http/Controllers/ContactoController.php +12 −2 Original line number Diff line number Diff line Loading @@ -570,6 +570,8 @@ public function upload(Request $request) 'csv_file' => 'required|mimes:csv,txt', ]); $profesiones = Profesion::select('id', 'nombre')->get(); $path = $request->file('csv_file')->getRealPath(); $content = file_get_contents($path); $content = str_replace("\xEF\xBB\xBF", '', $content); Loading @@ -583,7 +585,9 @@ public function upload(Request $request) } $row = array_combine($header, $row); $contacto = Contacto::create([ $existProfesion = $profesiones->firstWhere('nombre', $row['profesion']); $datosContacto = [ 'nombre' => $row['nombre'], 'ap_paterno' => $row['ap_paterno'], 'ap_materno' => $row['ap_materno'], Loading @@ -604,7 +608,13 @@ public function upload(Request $request) 'pais_par' => $row['pais_par'], 'finado' => $row['finado'], 'foto_perfil' => 'assets/images/profile-icon.webp' ]); ]; if(isset($existProfesion)){ $datosContacto['profesion_id'] = $existProfesion->id; } $contacto = Contacto::create($datosContacto); // Procesar teléfonos $prefijos = explode(';', $row['prefijo']); Loading Loading
app/Http/Controllers/ContactoController.php +12 −2 Original line number Diff line number Diff line Loading @@ -570,6 +570,8 @@ public function upload(Request $request) 'csv_file' => 'required|mimes:csv,txt', ]); $profesiones = Profesion::select('id', 'nombre')->get(); $path = $request->file('csv_file')->getRealPath(); $content = file_get_contents($path); $content = str_replace("\xEF\xBB\xBF", '', $content); Loading @@ -583,7 +585,9 @@ public function upload(Request $request) } $row = array_combine($header, $row); $contacto = Contacto::create([ $existProfesion = $profesiones->firstWhere('nombre', $row['profesion']); $datosContacto = [ 'nombre' => $row['nombre'], 'ap_paterno' => $row['ap_paterno'], 'ap_materno' => $row['ap_materno'], Loading @@ -604,7 +608,13 @@ public function upload(Request $request) 'pais_par' => $row['pais_par'], 'finado' => $row['finado'], 'foto_perfil' => 'assets/images/profile-icon.webp' ]); ]; if(isset($existProfesion)){ $datosContacto['profesion_id'] = $existProfesion->id; } $contacto = Contacto::create($datosContacto); // Procesar teléfonos $prefijos = explode(';', $row['prefijo']); Loading