prasanth-j /
otpify
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PrasanthJ\Otpify\Commands; |
||
| 4 | |||
| 5 | use Illuminate\Console\Command; |
||
| 6 | use PrasanthJ\Otpify\Models\Otp; |
||
| 7 | |||
| 8 | class CleanOtps extends Command |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The name and signature of the console command. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $signature = 'otpify:clean'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The console command description. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $description = 'Clean all verified tokens from the Otps table.'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create a new command instance. |
||
| 26 | * |
||
| 27 | * @return void |
||
| 28 | */ |
||
| 29 | public function __construct() |
||
| 30 | { |
||
| 31 | parent::__construct(); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Execute the console command. |
||
| 36 | * |
||
| 37 | * @return int |
||
| 38 | */ |
||
| 39 | public function handle() |
||
| 40 | { |
||
| 41 | $otps = Otp::where('verified', true); |
||
| 42 | |||
| 43 | $this->info("Found " . $otps->count() . " verified tokens."); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 44 | |||
| 45 | $otps->delete(); |
||
| 46 | |||
| 47 | $this->info("Verified tokens deleted successfully."); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |