command reminder add check company has action

This commit is contained in:
Cüneyt Şentürk 2020-10-02 10:40:18 +03:00
parent b2062a052b
commit b1d3f0bb8b
2 changed files with 12 additions and 2 deletions

View File

@ -36,9 +36,14 @@ class BillReminder extends Command
config(['laravel-model-caching.enabled' => false]); config(['laravel-model-caching.enabled' => false]);
// Get all companies // Get all companies
$companies = Company::enabled()->cursor(); $companies = Company::enabled()->withCount('bills')->cursor();
foreach ($companies as $company) { foreach ($companies as $company) {
// Has company bills
if (!$company->bills_count) {
continue;
}
$this->info('Sending bill reminders for ' . $company->name . ' company.'); $this->info('Sending bill reminders for ' . $company->name . ' company.');
// Set company id // Set company id

View File

@ -36,9 +36,14 @@ class InvoiceReminder extends Command
config(['laravel-model-caching.enabled' => false]); config(['laravel-model-caching.enabled' => false]);
// Get all companies // Get all companies
$companies = Company::enabled()->cursor(); $companies = Company::enabled()->withCount('invoices')->cursor();
foreach ($companies as $company) { foreach ($companies as $company) {
// Has company invoices
if (!$company->invoices_count) {
continue;
}
$this->info('Sending invoice reminders for ' . $company->name . ' company.'); $this->info('Sending invoice reminders for ' . $company->name . ' company.');
// Set company id // Set company id