Cleanup Command
Closed this issue · 5 comments
m1guelpf commented
Add an artisan command to remove expired invites from the database. I can do it if you want.
clarkeash commented
I'd be happy to add this, you are welcome to do the work. Happy to help if you need any assistance.
m1guelpf commented
@clarkeash Would this work?
use Clarkeash\Doorman\Models\Invite;
public function handle()
{
Invite::useless()->delete();
}
clarkeash commented
why not do something along the lines of:
Invite::where('valid_until', '<', Carbon::now())->delete();
m1guelpf commented
@clarkeash That doesn't cover the max uses reached case. I would move the is_expired logic to the expired property (#12)
clarkeash commented
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.