12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Plan;
- use App\Utils\Helper;
- use Illuminate\Console\Command;
- use App\Models\User;
- use Illuminate\Support\Facades\DB;
- class ResetUser extends Command
- {
- protected $builder;
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'reset:user';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '重置所有用户信息';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- if (!$this->confirm("确定要重置所有用户安全信息吗?")) {
- return;
- }
- ini_set('memory_limit', -1);
- $users = User::all();
- foreach ($users as $user)
- {
- $user->token = Helper::guid();
- $user->uuid = Helper::guid(true);
- $user->save();
- $this->info("已重置用户{$user->email}的安全信息");
- }
- }
- }
|