File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Console \Commands ;
4+
5+ use App \Models \LoginToken ;
6+ use Illuminate \Console \Command ;
7+
8+ class CleanLoginTokensTable extends Command
9+ {
10+ /**
11+ * The name and signature of the console command.
12+ *
13+ * @var string
14+ */
15+ protected $ signature = 'system:clean-login-tokens-table ' ;
16+
17+ /**
18+ * The console command description.
19+ *
20+ * @var string
21+ */
22+ protected $ description = 'Clean Login Tokens table to improve overall performance ' ;
23+
24+ /**
25+ * Execute the console command.
26+ */
27+ public function handle ()
28+ {
29+ // remove old stale tokens
30+ LoginToken::where ('created_at ' , '< ' , now ()->subWeeks (1 ))
31+ ->delete ();
32+
33+ // remove consumed tokens.
34+ // For analytics sake, we can maybe only rely on the first
35+ // option. We can track how often users use the magic link
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class Kernel extends ConsoleKernel
1313 protected function schedule (Schedule $ schedule ): void
1414 {
1515 $ schedule ->command ('sitemap:generate ' )->daily ();
16+ $ schedule ->command ('system:clean-login-tokens-table ' )->daily ();
1617 }
1718
1819 /**
You can’t perform that action at this time.
0 commit comments