コード例 #1
0
 /**
  * Handles avatar deletion
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getDeleteAvatar()
 {
     if (Settings::get('use_avatars')) {
         Session::put('profile_tab', 'avatar');
         $response = null;
         // If avatar presented - delete it
         if (Auth::user()->avatar) {
             $response = Icr::deleteImage(Auth::user()->avatar, 'avatar');
         }
         // Handle delete error
         if ($response instanceof \Exception) {
             flash()->error($response->getMessage());
             return redirect()->back();
         }
         Auth::user()->deleteAvatar();
         flash()->success(trans('users.avatar_deleted'));
     }
     return redirect()->back();
 }
コード例 #2
0
 /**
  * Deletes user avatar
  *
  * @param int $id User id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getDeleteAvatar($id)
 {
     if (Settings::get('use_avatars')) {
         $user = User::find($id);
         $response = Icr::deleteImage($user->avatar, 'avatar');
         if ($response instanceof \Exception) {
             flash()->error($response->getMessage());
             return redirect()->back();
         }
         $user->deleteAvatar();
         $user->save();
         flash()->success(trans('users.avatar_deleted'));
         User::flushCache($user);
     }
     return redirect()->back();
 }