Commit 3177052b authored by Alfonso Rafael Solis Rangel's avatar Alfonso Rafael Solis Rangel
Browse files

Implementacion de profesiones

parent 90e5229a
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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); 
@@ -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'],
@@ -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']);