From ee03ae700353de4eef9a38a817da5f62c58910a6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 14 Jan 2018 15:20:45 +0200 Subject: [PATCH] Sending reminders command: Trying to get property of non-object #1806 --- app/Ninja/Repositories/InvoiceRepository.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 871d4dc1bbd4..294f92772a6c 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -1208,9 +1208,14 @@ class InvoiceRepository extends BaseRepository public function findNeedingEndlessReminding(Account $account) { - $frequencyId = $account->account_email_settings->frequency_id_reminder4; - $frequency = Utils::getFromCache($frequencyId, 'frequencies'); + $settings = $account->account_email_settings; + $frequencyId = $settings->frequency_id_reminder4; + if (! $frequencyId || ! $account->enable_reminder4) { + return []; + } + + $frequency = Utils::getFromCache($frequencyId, 'frequencies'); $lastSentDate = date_create(); $lastSentDate->sub(date_interval_create_from_date_string($frequency->date_interval));