Sentinel\Repositories\User\SentryUserRepository::ban PHP Method

ban() public method

Ban a user
public ban ( integer $id ) : Array
$id integer
return Array
    public function ban($id)
    {
        try {
            $user = $this->sentry->getUserProvider()->findById($id);
            // Find the user using the user id
            $throttle = $this->sentry->findThrottlerByUserId($user->id);
            // Ban the user
            $throttle->ban();
            // Clear the persist code
            $user->persist_code = null;
            $user->save();
            // Fire the 'banned user' event
            $this->dispatcher->fire('sentinel.user.banned', ['user' => $user]);
            return new SuccessResponse(trans('Sentinel::users.banned'), ['userId' => $id]);
        } catch (UserNotFoundException $e) {
            $message = trans('Sentinel::sessions.invalid');
            return new ExceptionResponse($message);
        }
    }