clarkeash/doorman

Cleanup Command

Closed this issue · 5 comments

Add an artisan command to remove expired invites from the database. I can do it if you want.

I'd be happy to add this, you are welcome to do the work. Happy to help if you need any assistance.

@clarkeash Would this work?

use Clarkeash\Doorman\Models\Invite;

public function handle()
{
Invite::useless()->delete();
}

why not do something along the lines of:

Invite::where('valid_until', '<', Carbon::now())->delete();

@clarkeash That doesn't cover the max uses reached case. I would move the is_expired logic to the expired property (#12)

I have added some query scopes to the Invite model.

  • Invite::expired() - return all expired invites.
  • Invite::full() - return all full (max uses reached) invites.
  • Invite::useless() - return all expired and full invites.

Now you can just do:

Invite::useless()->delete();

to remove useless invites from the database.