where('created_at', '<', now()->subHour())->chunk(100, function ($hosts) { foreach ($hosts as $host) { $http = Http::remote($host->module->api_token, $host->module->url); $response = $http->get('hosts/' . $host->id); if ($response->status() === 404) { dispatch(new \App\Jobs\Remote\Host($host, 'delete')); } } }); } }