upgradeUserVmessId.php 786 B

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