option('user'); $all = (bool) $this->option('all-unverified'); $dryRun = (bool) $this->option('dry-run'); if ($one === '' && ! $all) { $this->error('Pass either --user= or --all-unverified.'); return self::FAILURE; } if ($one !== '') { $query = ctype_digit($one) ? User::where('id', (int) $one) : User::where('email', $one); $users = $query->get(); } else { $users = User::whereNull('email_verified_at')->get(); } if ($users->isEmpty()) { $this->warn('No matching users.'); return self::SUCCESS; } $sent = 0; $skipped = 0; foreach ($users as $user) { if ($user->hasVerifiedEmail()) { $skipped++; $this->line(" skip #{$user->id} <{$user->email}> — already verified"); continue; } if ($dryRun) { $this->line(" would #{$user->id} <{$user->email}>"); continue; } // sendEmailVerificationNotification is already SafeNotifier-wrapped // and will log instead of throwing on SMTP errors. $user->sendEmailVerificationNotification(); $sent++; $this->line(" sent #{$user->id} <{$user->email}>"); } $this->info($dryRun ? "Dry run complete — {$users->count()} candidates, {$skipped} already verified." : "Done — {$sent} sent, {$skipped} skipped."); return self::SUCCESS; } }