ResetLog.php 1.1 KB

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