alert_email != '') && ($settings->audit_warning_days) && ($settings->alerts_enabled == 1)) { // Send a rollup to the admin, if settings dictate $recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) { return new \App\Models\Recipients\AlertRecipient($item); }); // Assets due for auditing $assets = Asset::whereNotNull('next_audit_date') ->DueOrOverdueForAudit($settings) ->orderBy('last_audit_date', 'asc')->get(); if ($assets->count() > 0) { $this->info(trans_choice('mail.upcoming-audits', $assets->count(), ['count' => $assets->count(), 'threshold' => $settings->audit_warning_days])); \Notification::send($recipients, new SendUpcomingAuditNotification($assets, $settings->audit_warning_days)); $this->info('Audit report sent to '.$settings->alert_email); } else { $this->info('No assets to be audited. No report sent.'); } } elseif ($settings->alert_email=='') { $this->error('Could not send email. No alert email configured in settings'); } elseif (!$settings->audit_warning_days) { $this->error('No audit warning days set in Admin Notifications. No mail will be sent.'); } elseif ($settings->alerts_enabled!=1) { $this->info('Alerts are disabled in the settings. No mail will be sent'); } else { $this->error('Something went wrong. :( '); $this->error('Admin Notifications Email Setting: '.$settings->alert_email); $this->error('Admin Audit Warning Setting: '.$settings->audit_warning_days); $this->error('Admin Alerts Emnabled: '.$settings->alerts_enabled); } } }