clarkeash / doorman

Limit access to your Laravel applications by using invite codes
https://packagist.org/packages/clarkeash/doorman
MIT License
1.02k stars 45 forks source link

Reedem without exceptions #8

Closed m1guelpf closed 7 years ago

m1guelpf commented 7 years ago

It would be cool to have a reedem-like exception, but that returns true or false instead of throwing exceptions. I've had a look at the code, and it'd be easy to implement, but I couldn't come up with a namefor the function :rofl:

clarkeash commented 7 years ago

The check method will provide you will a true/false value.

m1guelpf commented 7 years ago

@clarkeash But it doesn't increment the uses. I was asking for a reedem-like function but returning a boolean and without throwing anything.

clarkeash commented 7 years ago

I don't see it being hard just to catch the DoormanException.

You could even add your own custom function if you wanted:

function redeem($code, $email) 
{
    try {
        Doorman::redeem($code, $email);
        return true;
    } catch (DoormanException $e) {
        return false;
    }
}

I am going to close this out for now as I am failing to see a use case.