mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Databases;
|
|
|
|
use App\Models\Backup;
|
|
use App\Models\BackupFile;
|
|
use App\Models\Database;
|
|
use App\Models\Server;
|
|
use App\Traits\HasCustomPaginationView;
|
|
use App\Traits\RefreshComponentOnBroadcast;
|
|
use Illuminate\Contracts\View\View;
|
|
use Livewire\Component;
|
|
|
|
class DatabaseBackupFiles extends Component
|
|
{
|
|
use HasCustomPaginationView;
|
|
use RefreshComponentOnBroadcast;
|
|
|
|
public Server $server;
|
|
|
|
public Backup $backup;
|
|
|
|
public string $restoreId = '';
|
|
|
|
public string $restoreDatabaseId = '';
|
|
|
|
public int $deleteId;
|
|
|
|
public function backup(): void
|
|
{
|
|
$this->backup->run();
|
|
|
|
$this->refreshComponent([]);
|
|
}
|
|
|
|
public function restore(): void
|
|
{
|
|
/** @var BackupFile $file */
|
|
$file = BackupFile::query()->findOrFail($this->restoreId);
|
|
|
|
/** @var Database $database */
|
|
$database = Database::query()->findOrFail($this->restoreDatabaseId);
|
|
|
|
$file->restore($database);
|
|
|
|
$this->refreshComponent([]);
|
|
|
|
$this->dispatchBrowserEvent('restored', true);
|
|
}
|
|
|
|
public function delete(): void
|
|
{
|
|
/** @var BackupFile $file */
|
|
$file = BackupFile::query()->findOrFail($this->deleteId);
|
|
|
|
$file->delete();
|
|
|
|
$this->dispatchBrowserEvent('confirmed', true);
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.databases.database-backup-files', [
|
|
'files' => $this->backup->files()->orderByDesc('id')->simplePaginate(10),
|
|
]);
|
|
}
|
|
}
|