This commit is contained in:
Bozhidar 2024-05-01 01:44:05 +03:00
parent 02bfdbb1ee
commit 72e7229539
2 changed files with 37 additions and 15 deletions

View file

@ -0,0 +1,37 @@
<?php
namespace app\Console\Commands;
use App\Models\Backup;
use App\Models\HostingSubscription;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDailyFullBackup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'phyre:create-daily-full-backup';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
$backup = new Backup();
$backup->backup_type = 'full';
$backup->save();
}
}

View file

@ -36,21 +36,6 @@ class RunBackup extends Command
$backup->delete();
}
$findBackupsToday = Backup::where('created_at', '>=', Carbon::now()->subHours(24))
->where(function ($query) {
$query->where('status', 'completed')
->orWhere('status', 'processing');
})
->first();
if (! $findBackupsToday) {
$backup = new Backup();
$backup->backup_type = 'full';
$backup->save();
} else {
$this->info('We already have a backup for today.');
}
// Check for pending backups
$getPendingBackups = Backup::where('status', 'pending')
->get();