diff --git a/app/Jobs/Host/SuspendOverdueHosts.php b/app/Jobs/Host/SuspendOverdueHosts.php new file mode 100644 index 0000000..df1a429 --- /dev/null +++ b/app/Jobs/Host/SuspendOverdueHosts.php @@ -0,0 +1,47 @@ +host = $host; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle(): void + { + if (!$this->host) { + Host::where('next_due_at', '<', now()) + ->where('status', '!=', 'suspended') + ->chunk(100, function ($hosts) { + foreach ($hosts as $host) { + dispatch(new self($host)); + } + }); + } + + $this->host?->suspend(); + } +}