This commit is contained in:
Bozhidar 2024-04-25 22:07:55 +03:00
parent 3f05a336e1
commit 23d1cb3adf
2 changed files with 4 additions and 26 deletions

View file

@ -36,28 +36,6 @@ class RunBackup extends Command
$backup->delete();
}
// // Find Hosting Subscriptions
// $findHostingSubscriptions = HostingSubscription::all();
// if ($findHostingSubscriptions->count() > 0) {
// foreach ($findHostingSubscriptions as $hostingSubscription) {
//
// $findBackup = Backup::where('hosting_subscription_id', $hostingSubscription->id)
// ->where('backup_type', 'hosting_subscription')
// ->where('created_at', '>=', Carbon::now()->subHours(24))
// ->first();
// if (! $findBackup) {
// $backup = new Backup();
// $backup->hosting_subscription_id = $hostingSubscription->id;
// $backup->backup_type = 'hosting_subscription';
// $backup->status = 'pending';
// $backup->save();
// } else {
// $this->error('Backup already exists for ' . $hostingSubscription->domain);
// $this->error('Created before: ' . $findBackup->created_at->diffForHumans());
// }
// }
// }
$findBackupsToday = Backup::where('created_at', '>=', Carbon::now()->subHours(24))
->first();

View file

@ -10,14 +10,14 @@ use Illuminate\Console\Command;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RunHostingSubscriptionBackup extends Command
class RunHostingSubscriptionsBackup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'phyre:run-hosting-subscription-backup';
protected $signature = 'phyre:run-hosting-subscriptions-backup';
/**
* The console command description.
@ -43,13 +43,13 @@ class RunHostingSubscriptionBackup extends Command
foreach ($findHostingSubscriptions as $hostingSubscription) {
$findBackup = HostingSubscriptionBackup::where('hosting_subscription_id', $hostingSubscription->id)
->where('backup_type', 'hosting_subscription')
->where('backup_type', 'full')
->where('created_at', '>=', Carbon::now()->subHours(24))
->first();
if (! $findBackup) {
$backup = new HostingSubscriptionBackup();
$backup->hosting_subscription_id = $hostingSubscription->id;
$backup->backup_type = 'hosting_subscription';
$backup->backup_type = 'full';
$backup->save();
} else {
$this->error('Backup already exists for ' . $hostingSubscription->domain);