public function destroy(UserRemoverListener $listener, $id)
    {
        $user = Foundation::make('orchestra.user')->findOrFail($id);

        // Avoid self-deleting accident.
        if ((string) $user->id === (string) Auth::user()->id) {
            return $listener->selfDeletionFailed();
        }

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

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

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

        return $listener->userDeleted();
    }
public function destroy(UserRemoverListener $listener, $id)
    {
        $user = Foundation::make('orchestra.user')->findOrFail($id);

        // Avoid self-deleting accident.
        if ((string) $user->id === (string) Auth::user()->id) {
            return $listener->selfDeletionFailed();
        }

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

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

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

        return $listener->userDeleted();
    }
public function destroy ( UserRemoverListener $ listener , $ id ) { $ user = Foundation :: make ( 'orchestra.user' ) -> findOrFail ( $ id ) ; // Avoid self-deleting accident. if ( ( string ) $ user -> id === ( string ) Auth :: user ( ) -> id ) { return $ listener -> selfDeletionFailed ( ) ; } try { $ this -> fireEvent ( 'deleting' , [ $ user ] ) ; $ user -> transaction ( function ( ) use ( $ user ) { $ user -> delete ( ) ; } ) ; $ this -> fireEvent ( 'deleted' , [ $ user ] ) ; } catch ( Exception $ e ) { return $ listener -> userDeletionFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> userDeleted ( ) ; }
Destroy a user.

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

@return mixed
Destroy a user .