info('Maintenance module is not enabled.'); return self::SUCCESS; } $moduleUtil = new ModuleUtil(); if (! $moduleUtil->isModuleInstalled('Maintenance')) { $this->info('Maintenance module is not installed.'); return self::SUCCESS; } $totals = ['reminders' => 0, 'work_orders' => 0]; Business::query()->select('id')->orderBy('id')->chunk(50, function ($rows) use ($moduleUtil, &$totals) { foreach ($rows as $row) { if ($moduleUtil->isSuperadminInstalled() && ! $moduleUtil->hasThePermissionInSubscription($row->id, 'maintenance_module')) { continue; } $business = Business::find($row->id); if (! $business) { continue; } $result = $this->scheduleService->processBusinessSchedules($business); $totals['reminders'] += $result['reminders']; $totals['work_orders'] += $result['work_orders']; $this->notificationService->scanAndNotify($business); } }); $this->info("Reminders sent: {$totals['reminders']}, work orders created: {$totals['work_orders']}."); return self::SUCCESS; } }