diff --git a/app/Console/Commands/CleanupExpiredTokens.php b/app/Console/Commands/CleanupExpiredTokens.php new file mode 100644 index 0000000..4a12f56 --- /dev/null +++ b/app/Console/Commands/CleanupExpiredTokens.php @@ -0,0 +1,35 @@ +delete(); + + if ($count > 0) { + Log::info("Cleaned up {$count} expired auth tokens"); + $this->info("Successfully cleaned up {$count} expired auth tokens."); + } else { + $this->info('No expired auth tokens found.'); + } + } catch (\Exception $e) { + Log::error('Error cleaning up expired auth tokens', [ + 'error' => $e->getMessage(), + 'trace' => $e->getTraceAsString(), + ]); + $this->error('Failed to clean up expired auth tokens.'); + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..454280e --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,28 @@ +command('auth:cleanup-expired-tokens')->daily(); + } + + /** + * Register the commands for the application. + */ + protected function commands(): void + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +}