minute = $minute; $this->host = $host; $this->onQueue('host-cost'); } /** * Execute the job. */ public function handle(): void { if (! $this->host) { $host = new Host(); if (app()->environment() != 'local') { $host = $host->where('minute_at', $this->minute); } $host->where('billing_cycle', 'hourly')->whereIn('status', ['running', 'stopped'])->with(['user', 'module'])->chunk(500, function ($hosts) { $hosts->each(function ($host) { /* @var Host $host */ if ($host->module->isUp()) { dispatch(new self($this->minute, $host)); } }); }); } else { if (! $this->host->isNextMonthCancel() && ! $this->host->isTrial()) { $this->host->cost($this->host->getPrice()); } } } }