Beispiel #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  User $user
  * @return \Illuminate\Http\Response
  */
 public function update(UserRequest $request, User $user)
 {
     $user->update($request->only(['name', 'occupation', 'bio', 'email']));
     $files_id[] = $request->hasFile('photo') ? $this->uploadFile($user, $request->file('photo'), 'profile_photo') : $request->input('photo_id');
     $files_id[] = $request->hasFile('cover') ? $this->uploadFile($user, $request->file('cover'), 'profile_cover') : $request->input('cover_id');
     $user->files()->sync($files_id);
     session()->flash('flash_message', 'Se han actualizado los datos de perfil');
     return redirect('admin/settings?tab=profile');
 }
Beispiel #2
0
 /**
  * Update profile
  *
  * @return Response
  */
 public function postUpdate(\App\Http\Requests\UserRequest $request)
 {
     $user_id = $this->auth->user()->id;
     $this->user->updateProfile($user_id, $request->all());
     if ($request->hasFile('avatar')) {
         $this->user->updateAvatar($user_id, $request->file('avatar'));
     }
     if ($request->hasFile('cover')) {
         $this->user->updateCover($user_id, $request->file('cover'));
     }
     return redirect()->action('UserController@getUpdate')->with('flash_message', trans('user.update_success'));
 }
 public function atualiza(UserRequest $request)
 {
     $id = Auth::user()->id;
     $user = User::find($id);
     $user->name = $request->nome;
     // Verifica se usuário deseja alterar a foto
     if ($request->hasFile('foto')) {
         $user->photo = '/' . $request->file('foto')->move('img/uploads/users');
     }
     // Verifica a senha antiga
     if (Hash::check($request->senhaAntiga, Auth::user()->password)) {
         $user->password = Hash::make($request->senhaNova);
         $user->save();
         Auth::logout();
         return redirect()->action('HomeController@index');
     }
     $user->save();
     return redirect()->action('UserController@edita');
 }
Beispiel #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(UserRequest $request)
 {
     $user = new User();
     $user->name = $request->name;
     $user->gender = $request->gender;
     $user->email = $request->email;
     $user->phone = $request->phone;
     $user->username = $request->username;
     $user->address = $request->address;
     $user->designation = $request->designation;
     if ($request->default_password) {
         $user->password = Hash::make(User::DEFAULT_PASSWORD);
     } else {
         $user->password = Hash::make($request->password);
     }
     if ($request->hasFile('photo')) {
         $user->image = $this->imageModifier($request, $request->all()['photo']);
     }
     $user->save();
     return redirect('user')->with('message', 'User created successfully.');
 }
Beispiel #5
0
 public function postUpdate(UserRequest $request)
 {
     $user = $this->user->findById(Auth::user()->id);
     $user->name = $request->input('name');
     $user->fio = $request->input('fio');
     $user->phone_number = $request->input('phone');
     $user->address = $request->input('address');
     $user->birth = $request->input('birth');
     $user->get_news = $request->input('get_news');
     $user->email = $request->input('email');
     if ($request->hasFile('photo')) {
         try {
             $image = Image::make($request->file('photo'));
             //  check the directories
             if (!File::exists($this->saveImgDir)) {
                 File::makeDirectory($this->saveImgDir);
             }
             if (!File::exists($this->saveImgDir . '/avatars')) {
                 File::makeDirectory($this->saveImgDir . '/avatars');
             }
             if (!File::exists($this->saveImgDir . '/avatars/' . $user->id)) {
                 File::makeDirectory($this->saveImgDir . '/avatars/' . $user->id);
             }
             // dir to save image
             $dir = $this->saveImgDir . '/avatars/' . $user->id;
             if (!File::exists($dir)) {
                 File::makeDirectory($dir);
             }
             // save medium
             $image->fit(240, 240)->save($dir . '/avatar.jpg');
             $user->photo = $dir . '/avatar.jpg';
         } catch (Exception $e) {
             dd($e);
         }
     } else {
         dd(56);
     }
     $user->save();
     return view('user.profile')->withUser($user);
 }
 public function update(UserRequest $request, $id)
 {
     if ($this->currentUser->hasAccess('wts.user.edit')) {
         DB::transaction(function () use($request) {
             // Update the user
             $user = Sentry::findUserById(Crypt::decrypt($request->id));
             if ($request->has('send_sms') && $request->send_sms == 1) {
                 if ($request->has('password')) {
                     $user->password = $request->password;
                     CommonController::sendSms('RHPOZTFYAY', $user->phone, 'Merhaba  "' . $user->first_name . ' ' . $user->last_name . '" WTS iş takip sistemi için; \\nEmailiniz : ' . $request->email . ' \\nŞifreniz: ' . $request->password . '\\nGüvenliğiniz açısından şifrenizi kimseyle paylaşmamanızı ve en kısa sürede değiştirmenizi önermekteyiz.\\nSite: wts.pinnacle.com.tr');
                 } else {
                     CommonController::sendSms('RHPOZTFYAY', $user->phone, 'Merhaba  "' . $user->first_name . ' ' . $user->last_name . '" WTS iş takip sistemi için; \\nEmailiniz : ' . $request->email . '\\nGüvenliğiniz açısından emailinizi kimseyle paylaşmamanızı ve şifrenizi düzenli aralıklarla değiştirmenizi önermekteyiz.\\nSite: wts.pinnacle.com.tr');
                 }
             }
             $user->email = $request->email;
             $user->first_name = $request->first_name;
             $user->last_name = $request->last_name;
             $user->phone = $request->phone;
             $user->slug = $request->slug_name;
             $user->save();
             // Find the group using the group id
             $groupId = Crypt::decrypt($request->group);
             if ($user->getGroups()[0]->id != $groupId) {
                 $newGroup = Sentry::findGroupById($groupId);
                 $user->updateGroups($newGroup);
             }
             if ($request->image_hidden) {
                 $file_path = public_path() . "/uploads/profile-images/" . $user->image;
                 \File::delete($file_path);
             }
             if ($request->hasFile('image')) {
                 $file = $request->file('image');
                 $imageName = CommonController::imageUpload($file, 'uploads/profile-images');
                 $user->image = $imageName;
                 $user->save();
             }
         });
         return response()->json($this->editResponseMessage);
     } else {
         abort(403, $this->accessForbidden);
     }
 }
Beispiel #7
0
 public function update(UserRequest $request, $id)
 {
     $data = $request->all();
     $model = Users::find($id);
     autoAssignDataToProperty($model, $request->all());
     if ($request->hasFile('avatar')) {
         $file = $request->file('avatar');
         $name = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $picture = time() . $name . '.' . $extension;
         $request->file('avatar')->move('images/avatar', $picture);
         $filename = 'images/avatar/' . $picture;
     } else {
         $image = $model->toArray();
         $filename = $image['avatar'];
     }
     $password = bcrypt($request->input('password'));
     $model->password = $password;
     $model->avatar = $filename;
     $model->save();
     return redirect()->action('Admin\\UsersController@index')->withSuccess(Lang::get('messages.update_success'));
 }
 public function updateProfile(UserRequest $request, Guard $auth)
 {
     $pathUser = '******';
     \Storage::makeDirectory($pathUser);
     $user = User::findOrFail($auth->id());
     $user->fill($request->all());
     if ($request->hasFile('avatar')) {
         $Documento = $request->file('avatar');
         $nombre = \Hash::make($Documento->getClientOriginalName());
         $nombre = str_replace('/', 'Y', $nombre);
         $nombre = $nombre . '.' . $Documento->guessExtension();
         $fullPath = $pathUser . '/' . $nombre;
         \Storage::disk('local')->put($fullPath, \File::get($Documento));
         $user->avatar = 'documentos/' . $fullPath;
     } else {
         if ($request->get('delImgProfile') === 'true') {
             $user->avatar = 'avatar.jpg';
         }
     }
     $user->save();
     return redirect('home');
 }