2023-08-10 13:52:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project\Database;
|
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class BackupExecutions extends Component
|
|
|
|
{
|
|
|
|
public $backup;
|
|
|
|
public $executions;
|
2023-10-24 12:31:28 +00:00
|
|
|
public $setDeletableBackup;
|
|
|
|
protected $listeners = ['refreshBackupExecutions', 'deleteBackup'];
|
2023-08-10 13:52:54 +00:00
|
|
|
|
2023-10-24 12:31:28 +00:00
|
|
|
public function deleteBackup($exeuctionId)
|
|
|
|
{
|
|
|
|
$execution = $this->backup->executions()->where('id', $exeuctionId)->first();
|
|
|
|
if (is_null($execution)) {
|
|
|
|
$this->emit('error', 'Backup execution not found.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server);
|
|
|
|
$execution->delete();
|
|
|
|
$this->emit('success', 'Backup deleted successfully.');
|
|
|
|
$this->emit('refreshBackupExecutions');
|
|
|
|
}
|
2023-08-10 13:52:54 +00:00
|
|
|
public function refreshBackupExecutions(): void
|
|
|
|
{
|
2023-08-11 08:42:57 +00:00
|
|
|
$this->executions = $this->backup->executions;
|
2023-08-10 13:52:54 +00:00
|
|
|
}
|
|
|
|
}
|