ResetUser.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Plan;
  4. use App\Utils\Helper;
  5. use Illuminate\Console\Command;
  6. use App\Models\User;
  7. use Illuminate\Support\Facades\DB;
  8. class ResetUser extends Command
  9. {
  10. protected $builder;
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'reset:user';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = '重置所有用户信息';
  23. /**
  24. * Create a new command instance.
  25. *
  26. * @return void
  27. */
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. }
  32. /**
  33. * Execute the console command.
  34. *
  35. * @return mixed
  36. */
  37. public function handle()
  38. {
  39. if (!$this->confirm("确定要重置所有用户安全信息吗?")) {
  40. return;
  41. }
  42. ini_set('memory_limit', -1);
  43. $users = User::all();
  44. foreach ($users as $user)
  45. {
  46. $user->token = Helper::guid();
  47. $user->uuid = Helper::guid(true);
  48. $user->save();
  49. $this->info("已重置用户{$user->email}的安全信息");
  50. }
  51. }
  52. }