From 6a773ee38259dd482ab3f0d852fdb13c4d010d16 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 8 Dec 2016 21:51:21 +0100 Subject: [PATCH] add inactive user purge command --- app/Console/Command/PurgeInactiveUsers.php | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/Console/Command/PurgeInactiveUsers.php diff --git a/app/Console/Command/PurgeInactiveUsers.php b/app/Console/Command/PurgeInactiveUsers.php new file mode 100644 index 0000000..01e9abb --- /dev/null +++ b/app/Console/Command/PurgeInactiveUsers.php @@ -0,0 +1,39 @@ + + */ +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(); + } +}