diff --git a/app/Console/Commands/BackupUpdate.php b/app/Console/Commands/BackupUpdate.php index e4166e5ff5d2..b9b6ec0e7558 100644 --- a/app/Console/Commands/BackupUpdate.php +++ b/app/Console/Commands/BackupUpdate.php @@ -77,8 +77,8 @@ class BackupUpdate extends Command { set_time_limit(0); - Backup::whereRaw('html_backup IS NOT NULL')->chunk(5000, function ($backups) { - foreach ($backups as $backup) { + Backup::whereHas('activity')->whereRaw('html_backup IS NOT NULL')->cursor()->each( function ($backup) { + if(strlen($backup->html_backup) > 1 && $backup->activity->invoice->exists()){ @@ -97,7 +97,7 @@ class BackupUpdate extends Command } - } + }); } diff --git a/app/Models/Activity.php b/app/Models/Activity.php index ca8f0e8ab4c8..73c49f1dcd5a 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -177,6 +177,11 @@ class Activity extends StaticModel return $this->belongsTo(Invoice::class)->withTrashed(); } + public function credit() + { + return $this->belongsTo(Credit::class)->withTrashed(); + } + /** * @return mixed */