upgradeUserVmessId.php 668 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Http\Models\User;
  4. use Illuminate\Console\Command;
  5. use Log;
  6. class upgradeUserVmessId extends Command
  7. {
  8. protected $signature = 'upgradeUserVmessId';
  9. protected $description = '重新生成用户的vmess_id字段';
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. public function handle()
  15. {
  16. $userList = User::query()->get();
  17. foreach($userList as $user){
  18. if(!isset($user->vmess_id)){
  19. Log::error("USER表缺失vmess_id字段,请先维护数据库字典");
  20. break;
  21. }
  22. if(!$user->vmess_id){
  23. User::query()->where('id', $user->id)->update(['vmess_id' => createGuid()]);
  24. }
  25. }
  26. }
  27. }