/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $user = User::find($id); if (Input::get('lastname')) { $user->lastname = Input::get('lastname'); } if (Input::get('firstname')) { $user->firstname = Input::get('firstname'); } if (Input::get('username')) { $user->username = Input::get('username'); } if (Input::get('email')) { $user->email = Input::get('email'); } if (Input::get('password')) { $user->password = Hash::make(Input::get('password')); } if (Input::get('position')) { $user->position = Input::get('position'); } if (Input::get('identification')) { $user->identification = Input::get('identification'); } if (Input::get('telephone')) { $user->telephone = Input::get('telephone'); } if (Input::get('cellphone')) { $user->cellphone = Input::get('cellphone'); } if (Input::get('enable')) { $user->enable = Input::get('enable'); } if (Input::get('profile')) { $user->profile = Input::get('profile'); $profile = Input::get('profile'); $user->roles()->sync(User::makeProfile($profile)); } //Imagen relacionada if (Input::hasFile('file')) { AttachmentController::destroyAllBy('user_id', $user->id); $f = Input::file('file'); if ($f) { $att = new Attachment(); $att->user_id = $user->id; $r = array(); $r = AttachmentController::uploadAttachment($f, $att); } } $user->save(); return Redirect::to('admin/user'); }
/** * Metodo para subir SOLO IMAGENES al servidor y guardarlo en el sistema de archivos * @param _FILE $file archivo que se esta subiendo * @param Attachment Entidad con toda la informacion de un archivo a guardar * @return JSON respuesta del proceso de carga de archivo */ public static function uploadImages($file, $attachment = '') { $arr_response = array(); $file_image = $file; $file = array('image' => $file_image); $rules = array('image' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000 // se valida que sea una imagen, esto es doble verificacion $validator = Validator::make($file, $rules); if ($validator->fails()) { $arr_response = array('valid' => false, 'error' => array('error' => $validator)); } else { $arr_response = AttachmentController::uploadAttachment($file, $attachment); } return $arr_response; }