with(['module', 'user'])->chunk(100, function ($hosts) { foreach ($hosts as $host) { $host->status = 'running'; $response = $host->module->http()->post('hosts', $host->toArray()); if (!$response->successful()) { $host->status = 'error'; } // dd($response); $response_json = $response->json(); // 检测是否有价格 if (isset($response_json['data']['price'])) { $host->price = $response_json['data']['price']; } else { $host->status = 'error'; } $host->save(); } }); } }