diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php index 101bb4593..18ec9cd96 100644 --- a/app/Livewire/Project/Database/BackupExecutions.php +++ b/app/Livewire/Project/Database/BackupExecutions.php @@ -2,11 +2,12 @@ namespace App\Livewire\Project\Database; +use App\Models\ScheduledDatabaseBackup; use Livewire\Component; class BackupExecutions extends Component { - public $backup; + public ?ScheduledDatabaseBackup $backup = null; public $executions = []; public $setDeletableBackup; public function getListeners() @@ -20,8 +21,11 @@ public function getListeners() public function cleanupFailed() { - $this->backup?->executions()->where('status', 'failed')->delete(); - $this->refreshBackupExecutions(); + if ($this->backup) { + $this->backup?->executions()->where('status', 'failed')->delete(); + $this->refreshBackupExecutions(); + $this->dispatch('success', 'Failed backups cleaned up.'); + } } public function deleteBackup($exeuctionId) { @@ -45,6 +49,6 @@ public function download_file($exeuctionId) } public function refreshBackupExecutions(): void { - $this->executions = $this->backup->executions()->get()->sortByDesc('created_at'); + $this->executions = $this->backup?->executions()->get()->sortByDesc('created_at'); } } diff --git a/app/Livewire/Settings/Backup.php b/app/Livewire/Settings/Backup.php index 121b73af8..82b3075c0 100644 --- a/app/Livewire/Settings/Backup.php +++ b/app/Livewire/Settings/Backup.php @@ -36,7 +36,7 @@ class Backup extends Component public function mount() { - $this->backup = $this->database?->scheduledBackups->first() ?? []; + $this->backup = $this->database?->scheduledBackups->first() ?? null; $this->executions = $this->backup?->executions ?? []; } public function add_coolify_database() diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php index 34e2b965d..dd96e13a9 100644 --- a/resources/views/livewire/project/database/backup-executions.blade.php +++ b/resources/views/livewire/project/database/backup-executions.blade.php @@ -1,54 +1,57 @@