0
私は顧客テーブルで何かしたいと思います。レコードがたくさんあるので、100レコードごとにチャンク関数を使用します。また、進捗状況を表示するための進捗バーを追加したいと思います。Laravelチャンク関数にプログレスバーを追加する方法
ただし、私が書いたコードは動作しません。 "$ bar"変数でエラーが発生します。
$count = DB::table('customers')->count();
$bar = $this->output->createProgressBar($count);
DB::table('customers')->chunk(100, function ($customers,$bar) {
foreach($customers as $customer) {
//do something with customer
$bar->advance();
}
$bar->finish();
}