option('database') !== null) { DB::setDefaultConnection($this->option('database')); } Comment::query()->chunk(100, function ($comments) use ($commentRepo) { foreach ($comments as $comment) { $comment->html = $commentRepo->commentToHtml($comment->text); $comment->save(); } }); DB::setDefaultConnection($connection); $this->comment('Comment HTML content has been regenerated'); return 0; } }