info("开始更新职位市辖区数据..."); $total = Jobs::where('sdistrict',556)->get()->count(); $bar=$this->output->createProgressBar($total); Jobs::where('sdistrict',556)->orderBy('id', 'asc')->chunk(1000, function ($jobs) use ($bar) { $jobs_arr = []; $this->handelJobs($jobs, $jobs_arr); if ($jobs_arr) { \App\Models\Jobs::whereIn('id',$jobs_arr)->update(['district'=>'11.129.1311']); } $bar->advance(1000); }); $bar->finish(); $this->line(" 完成!"); $this->info("更新职位市辖区数据成功."); } public function handelJobs($jobs, &$jobs_arr) { if (!$jobs->isEmpty()) { foreach ($jobs as $job) { $jobs_arr[] = $job->id; } } } }