Skip to content

Commit

Permalink
command reminder add check company has action
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Oct 2, 2020
1 parent b2062a0 commit b1d3f0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/Console/Commands/BillReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ public function handle()
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
Expand Down
7 changes: 6 additions & 1 deletion app/Console/Commands/InvoiceReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ public function handle()
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
Expand Down

0 comments on commit b1d3f0b

Please sign in to comment.