public function destroy(UserRemoverListener $listener, $id)
    {
        if (user()->id == $id) {
            return $listener->userDeletionFailed(['error' => trans('antares/acl::messages.unable_to_delete_self')]);
        }
        $user = Foundation::make('antares.user');
        if (app('antares.acl')->make('antares/acl')->can('login-as-user')) {
            $user = $user->withoutGlobalScopes();
        }

        $user = $user->findOrFail($id);
        if ((string) $user->id === (string) Auth::user()->id) {
            return $listener->selfDeletionFailed();
        }

        try {
            $this->fireEvent('deleting', [$user]);

            DB::transaction(function () use ($user) {
                $user->delete();
            });

            $this->fireEvent('deleted', [$user]);
        } catch (Exception $e) {
            Log::emergency($e);
            return $listener->userDeletionFailed(['error' => $e->getMessage()]);
        }

        return $listener->userDeleted();
    }
public function destroy(UserRemoverListener $listener, $id)
    {
        if (user()->id == $id) {
            return $listener->userDeletionFailed(['error' => trans('antares/acl::messages.unable_to_delete_self')]);
        }
        $user = Foundation::make('antares.user');
        if (app('antares.acl')->make('antares/acl')->can('login-as-user')) {
            $user = $user->withoutGlobalScopes();
        }

        $user = $user->findOrFail($id);
        if ((string) $user->id === (string) Auth::user()->id) {
            return $listener->selfDeletionFailed();
        }

        try {
            $this->fireEvent('deleting', [$user]);

            DB::transaction(function () use ($user) {
                $user->delete();
            });

            $this->fireEvent('deleted', [$user]);
        } catch (Exception $e) {
            Log::emergency($e);
            return $listener->userDeletionFailed(['error' => $e->getMessage()]);
        }

        return $listener->userDeleted();
    }
public function destroy ( UserRemoverListener $ listener , $ id ) { if ( user ( ) -> id == $ id ) { return $ listener -> userDeletionFailed ( [ 'error' => trans ( 'antares/acl::messages.unable_to_delete_self' ) ] ) ; } $ user = Foundation :: make ( 'antares.user' ) ; if ( app ( 'antares.acl' ) -> make ( 'antares/acl' ) -> can ( 'login-as-user' ) ) { $ user = $ user -> withoutGlobalScopes ( ) ; } $ user = $ user -> findOrFail ( $ id ) ; if ( ( string ) $ user -> id === ( string ) Auth :: user ( ) -> id ) { return $ listener -> selfDeletionFailed ( ) ; } try { $ this -> fireEvent ( 'deleting' , [ $ user ] ) ; DB :: transaction ( function ( ) use ( $ user ) { $ user -> delete ( ) ; } ) ; $ this -> fireEvent ( 'deleted' , [ $ user ] ) ; } catch ( Exception $ e ) { Log :: emergency ( $ e ) ; return $ listener -> userDeletionFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> userDeleted ( ) ; }
Destroy a user.

@param  \Antares\Contracts\Foundation\Listener\Account\UserRemover  $listener
@param  string|int  $id

@return mixed
Destroy a user .