add inactive user purge command
This commit is contained in:
parent
dd8d87aa07
commit
6a773ee382
1 changed files with 39 additions and 0 deletions
39
app/Console/Command/PurgeInactiveUsers.php
Normal file
39
app/Console/Command/PurgeInactiveUsers.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the inactive user purger.
|
||||||
|
* @package Sakura
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Sakura\Console\Command;
|
||||||
|
|
||||||
|
use CLIFramework\Command;
|
||||||
|
use Sakura\DB;
|
||||||
|
use Sakura\Forum\Post;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purges users that have been inactive for 30 days or more.
|
||||||
|
* @package Sakura
|
||||||
|
* @author Julian van de Groep <me@flash.moe>
|
||||||
|
*/
|
||||||
|
class PurgeInactiveUsers extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A quick description of this command.
|
||||||
|
* @return string.
|
||||||
|
*/
|
||||||
|
public function brief(): string
|
||||||
|
{
|
||||||
|
return "Purges users that have been inactive for 30 days or more.";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the repository installing.
|
||||||
|
*/
|
||||||
|
public function execute(): void
|
||||||
|
{
|
||||||
|
DB::table('users')
|
||||||
|
->where('user_activated', 0)
|
||||||
|
->where('user_last_online', '<', time() - (30 * 24 * 60 * 60))
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue