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

Cleanup Command #10

Closed m1guelpf closed 7 years ago

m1guelpf commented 7 years ago

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

clarkeash commented 7 years ago

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

m1guelpf commented 7 years ago

@clarkeash Would this work?

use Clarkeash\Doorman\Models\Invite;

public function handle()
{
Invite::useless()->delete();
}
clarkeash commented 7 years ago

why not do something along the lines of:

Invite::where('valid_until', '<', Carbon::now())->delete();
m1guelpf commented 7 years ago

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

clarkeash commented 7 years ago

I have added some query scopes to the Invite model.

Now you can just do:

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

to remove useless invites from the database.