argument('id')) { $query->where('id', $id); } elseif (! $this->option('all')) { $this->error('Pass a post ID or use --all'); return self::FAILURE; } $posts = $query->get(); if ($posts->isEmpty()) { $this->info('No posts to repair'); return self::SUCCESS; } $changed = 0; foreach ($posts as $post) { $cleaned = $normalizer->normalize((string) $post->content); if ($cleaned === $post->content) { continue; } if ($this->option('dry-run')) { $this->line("[{$post->id}] {$post->title}"); continue; } $post->content = $cleaned; $post->save(); $changed++; } $this->info($this->option('dry-run') ? 'Preview only, nothing written' : "Repaired {$changed} posts"); return self::SUCCESS; } }