public function destroy(BannedEmailListener $listener, $id)
    {
        $bannedEmail = $this->repository->findById($id);

        if (!$bannedEmail) {
            return $listener->notFound($id);
        }

        try {
            $this->fireEvent('deleting', [$bannedEmail]);
            $this->repository->delete($bannedEmail);
            $this->bannedEmailsService->saveToFile();
            $this->fireEvent('deleted', [$bannedEmail]);
        } catch (Exception $e) {
            Log::critical($e->getMessage());
            return $listener->deleteBannedEmailFailed(['error' => $e->getMessage()]);
        }

        return $listener->deleteBannedEmailSuccess();
    }
public function destroy(BannedEmailListener $listener, $id)
    {
        $bannedEmail = $this->repository->findById($id);

        if (!$bannedEmail) {
            return $listener->notFound($id);
        }

        try {
            $this->fireEvent('deleting', [$bannedEmail]);
            $this->repository->delete($bannedEmail);
            $this->bannedEmailsService->saveToFile();
            $this->fireEvent('deleted', [$bannedEmail]);
        } catch (Exception $e) {
            Log::critical($e->getMessage());
            return $listener->deleteBannedEmailFailed(['error' => $e->getMessage()]);
        }

        return $listener->deleteBannedEmailSuccess();
    }
public function destroy ( BannedEmailListener $ listener , $ id ) { $ bannedEmail = $ this -> repository -> findById ( $ id ) ; if ( ! $ bannedEmail ) { return $ listener -> notFound ( $ id ) ; } try { $ this -> fireEvent ( 'deleting' , [ $ bannedEmail ] ) ; $ this -> repository -> delete ( $ bannedEmail ) ; $ this -> bannedEmailsService -> saveToFile ( ) ; $ this -> fireEvent ( 'deleted' , [ $ bannedEmail ] ) ; } catch ( Exception $ e ) { Log :: critical ( $ e -> getMessage ( ) ) ; return $ listener -> deleteBannedEmailFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> deleteBannedEmailSuccess ( ) ; }
Removes the banned email from the repository.

@param BannedEmailListener $listener
@param int $id
@return mixed
Removes the banned email from the repository .