BookStack\Http\Controllers\UserController::destroy PHP Method

destroy() public method

Remove the specified user from storage.
public destroy ( integer $id ) : Illuminate\Http\Response
$id integer
return Illuminate\Http\Response
    public function destroy($id)
    {
        $this->preventAccessForDemoUsers();
        $this->checkPermissionOr('users-manage', function () use($id) {
            return $this->currentUser->id == $id;
        });
        $user = $this->userRepo->getById($id);
        if ($this->userRepo->isOnlyAdmin($user)) {
            session()->flash('error', 'You cannot delete the only admin');
            return redirect($user->getEditUrl());
        }
        if ($user->system_name === 'public') {
            session()->flash('error', 'You cannot delete the guest user');
            return redirect($user->getEditUrl());
        }
        $this->userRepo->destroy($user);
        session()->flash('success', 'User successfully removed');
        return redirect('/settings/users');
    }