Fixed recurring check console remove template..

This commit is contained in:
Cüneyt Şentürk 2023-03-15 18:16:34 +03:00
parent f59848c436
commit 3b1f8c93ff

View File

@ -71,12 +71,18 @@ class RecurringCheck extends Command
$company_name = !empty($recur->company->name) ? $recur->company->name : 'Missing Company Name : ' . $recur->company->id; $company_name = !empty($recur->company->name) ? $recur->company->name : 'Missing Company Name : ' . $recur->company->id;
$template = $recur->recurable()->where('company_id', $recur->company_id)->first();
// Check if company is disabled // Check if company is disabled
if (! $recur->company->enabled) { if (! $recur->company->enabled) {
$this->info($company_name . ' company is disabled. Skipping...'); $this->info($company_name . ' company is disabled. Skipping...');
if (Date::parse($recur->company->updated_at)->format('Y-m-d') > Date::now()->subMonth(3)->format('Y-m-d')) { if (Date::parse($recur->company->updated_at)->format('Y-m-d') > Date::now()->subMonth(3)->format('Y-m-d')) {
$recur->delete(); $recur->delete();
if ($template) {
$template->delete();
}
} }
continue; continue;
@ -98,12 +104,16 @@ class RecurringCheck extends Command
$recur->delete(); $recur->delete();
if ($template) {
$template->delete();
}
continue; continue;
} }
company($recur->company_id)->makeCurrent(); company($recur->company_id)->makeCurrent();
if (! $template = $recur->recurable) { if (! $template) {
$this->info('Missing model.'); $this->info('Missing model.');
$recur->delete(); $recur->delete();