clarkeash/doorman

Add an expired function to the model

Closed this issue · 4 comments

It would be cool (and very useful to #10) to have an setExpiredAttribute() function on the Invite model, so you can do $invite->expired and get a boolean

how would you use this in #10 ?

@clarkeash Commented #10 code, now you can see it.

@clarkeash Would this work?

use Carbon\Carbon;
public function setExpiredAttribute()
{
return $this->getAttribute('valid_until') > Carbon::now() && $this->getAttribute('max') => $this->getAttribute('uses');
}

I have added a few helper methods to the model:

  • hasExpired()
  • isFull()
  • isRestricted()
  • isRestrictedFor($email)
  • isUseless() - is full or expired.