option('yes') && ! $this->confirm('This will replace every user password with a secure random value and mark accounts as needing a reset. Continue?')) { $this->info('Aborted. No changes were made.'); return 0; } $chunk = (int) $this->option('chunk'); $count = DB::table('users')->count(); if ($count === 0) { $this->info('No users found.'); return 0; } $bar = $this->output->createProgressBar($count); $bar->start(); DB::table('users')->orderBy('id')->chunkById($chunk, function ($rows) use ($bar) { foreach ($rows as $row) { DB::table('users')->where('id', $row->id)->update([ 'password' => Hash::make(Str::random(64)), 'needs_password_reset' => true, 'updated_at' => now(), ]); $bar->advance(); } }, 'id'); $bar->finish(); $this->newLine(2); $this->info('All user passwords reset and accounts flagged for password reset.'); return 0; } }