Exemplo n.º 1
0
 public function index()
 {
     SecurityHelper::isLogin();
     $data = Input::all();
     // VALIDACIONES
     $rules = array('name' => 'required', 'lastname' => 'required', 'email' => 'required|email', 'password' => 'required|min:8', 'file' => 'mimes:jpeg,bmp,png|max:1000|min:1');
     $messages = array('required' => 'El campo :attribute debe ser completado.', 'email' => 'El mail es incorrecto.', 'min' => 'La clave debe tener al menos 8 caracteres.', 'mimes' => 'El archivo debe ser de un formato de imágen ( jpeg, bmp, png)', 'max' => 'La imágen no puede ser superior a 1Mega');
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->fails()) {
         $user = new User();
         $user->setName = Input::get('name');
         $user->setLastname = Input::get('lastname');
         $user->setEmail = Input::get('email');
         $user->setPassword = Crypt::encrypt(Input::get('password'));
         return Redirect::route('perfil_post', array('user' => $user))->withInput()->withErrors($validator);
     }
     // FIN VALIDACIONES
     // Controlo si subió o NO una imágen.
     if (Input::hasFile('file')) {
         $update_perfil = $this->_updatePerfil('with_new_image');
     } else {
         $update_perfil = $this->_updatePerfil('no_image');
     }
     // Controlo si pude hacer el update correctamente.
     if ($update_perfil) {
         $id = Auth::id();
         $user = User::find($id);
         $image_name = $user->image;
         Session::put('image_user', $image_name);
         return Redirect::to('homepage')->with('success', 'Su perfil fue editado correctamente.');
     } else {
         return Redirect::to('homepage')->with('error', 'No se pudo subir la imágen seleccionada.');
     }
 }
 public function toExport()
 {
     try {
         SecurityHelper::isLogin();
         $data = Input::all();
         // VALIDACION
         $messages = array('validate_file_cobranzas' => 'El archivo de cobranzas es incorrecto.', 'required' => 'El campo :attribute debe ser completado');
         $rules = array('file' => array('validate_file_cobranzas', 'required'));
         $validator = Validator::make($data, $rules, $messages);
         if ($validator->fails()) {
             return Redirect::to('pmc_export_excel')->withErrors($validator);
         }
         // FIN DE VALIDACION
         $data_array = $this->_createArray();
         $create_excel = $this->_createExcel($data_array);
         if ($create_excel != NULL) {
             $insert_file_db = $this->_insertFile($create_excel, 'cobranzas');
             //$send_email = $this->_sendEmailExcelCobranzas($create_excel);
             if ($insert_file_db) {
                 return Redirect::to('homepage')->with('success', 'El excel generado de cobranzas de Pagomiscuentas fue insertado en la base.');
             }
         } else {
             return Redirect::to('homepage')->with('error', 'No se pudo generar el excel de cobranzas de Pagomiscuentas. . . .');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }