ResetTraffic.php 960 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. use App\Models\Plan;
  6. use App\Models\User;
  7. class ResetTraffic extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'reset:traffic';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '流量清空';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. // get plans of cycle type
  38. $plans = Plan::where('type', 0)->get();
  39. $users = User::whereIn('plan_id', $plans)->get();
  40. $users->update([
  41. 'u' => 0,
  42. 'd' => 0
  43. ]);
  44. }
  45. }