45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Ui\System\Modal;
|
|
|
|
use App\Models\BackupJob;
|
|
use Livewire\Attributes\On;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class BackupDeleteModal extends ModalComponent
|
|
{
|
|
public int $jobId;
|
|
public string $filename = '';
|
|
|
|
public static function modalMaxWidth(): string { return 'sm'; }
|
|
|
|
public function mount(int $jobId): void
|
|
{
|
|
$job = BackupJob::findOrFail($jobId);
|
|
$this->jobId = $job->id;
|
|
$this->filename = $job->artifact_path ? basename($job->artifact_path) : '—';
|
|
}
|
|
|
|
#[On('backup:confirm-delete')]
|
|
public function delete(): void
|
|
{
|
|
$job = BackupJob::find($this->jobId);
|
|
if ($job) {
|
|
if ($job->artifact_path && file_exists($job->artifact_path)) {
|
|
@unlink($job->artifact_path);
|
|
}
|
|
$job->delete();
|
|
}
|
|
|
|
$this->dispatch('backup-list-refresh');
|
|
$this->dispatch('toast', type: 'done', badge: 'Backup',
|
|
title: 'Gelöscht', text: 'Backup-Eintrag wurde entfernt.', duration: 3000);
|
|
$this->closeModal();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.ui.system.modal.backup-delete-modal');
|
|
}
|
|
}
|