From b1d3f0bb8be615202f2dbfad95c7422bd9284006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 2 Oct 2020 10:40:18 +0300 Subject: [PATCH] command reminder add check company has action --- app/Console/Commands/BillReminder.php | 7 ++++++- app/Console/Commands/InvoiceReminder.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/BillReminder.php b/app/Console/Commands/BillReminder.php index 69cc3075a..27d879ddc 100644 --- a/app/Console/Commands/BillReminder.php +++ b/app/Console/Commands/BillReminder.php @@ -36,9 +36,14 @@ class BillReminder extends Command config(['laravel-model-caching.enabled' => false]); // Get all companies - $companies = Company::enabled()->cursor(); + $companies = Company::enabled()->withCount('bills')->cursor(); foreach ($companies as $company) { + // Has company bills + if (!$company->bills_count) { + continue; + } + $this->info('Sending bill reminders for ' . $company->name . ' company.'); // Set company id diff --git a/app/Console/Commands/InvoiceReminder.php b/app/Console/Commands/InvoiceReminder.php index d59aa8171..603e7bbdd 100644 --- a/app/Console/Commands/InvoiceReminder.php +++ b/app/Console/Commands/InvoiceReminder.php @@ -36,9 +36,14 @@ class InvoiceReminder extends Command config(['laravel-model-caching.enabled' => false]); // Get all companies - $companies = Company::enabled()->cursor(); + $companies = Company::enabled()->withCount('invoices')->cursor(); foreach ($companies as $company) { + // Has company invoices + if (!$company->invoices_count) { + continue; + } + $this->info('Sending invoice reminders for ' . $company->name . ' company.'); // Set company id