CheckUser.php 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\User;
  4. use Illuminate\Console\Command;
  5. class CheckUser extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'check:user';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = '用户检查任务';
  19. /**
  20. * Create a new command instance.
  21. *
  22. * @return void
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. }
  28. /**
  29. * Execute the console command.
  30. *
  31. * @return mixed
  32. */
  33. public function handle()
  34. {
  35. $this->resetExpiredUserPlan();
  36. }
  37. private function resetExpiredUserPlan($day = 14)
  38. {
  39. User::where('expired_at', '<', $day * 86400)
  40. ->whereNotNull('expired_at')
  41. ->update([
  42. 'plan_id' => NULL,
  43. 'group_id' => NULL
  44. ]);
  45. }
  46. }