ResetLog.php 898 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Plan;
  4. use App\Models\StatUser;
  5. use App\Utils\Helper;
  6. use Illuminate\Console\Command;
  7. use App\Models\User;
  8. use Illuminate\Support\Facades\DB;
  9. class ResetLog extends Command
  10. {
  11. protected $builder;
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'reset:log';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = '清空日志';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. StatUser::where('record_at', '<', strtotime('-2 month', time()))
  41. ->delete();
  42. }
  43. }