From 8c28e45c9891d5e149a4cab51d1b10b28100eaf7 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Mon, 13 Feb 2023 02:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=98=9F=E5=88=97?= =?UTF-8?q?=E6=9A=82=E5=81=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/Host/SuspendOverdueHosts.php | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/Jobs/Host/SuspendOverdueHosts.php 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(); + } +}