2026-07-15 13:47:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Project\Application\Backup;
|
|
|
|
|
|
|
|
|
|
use App\Models\Application;
|
|
|
|
|
use App\Models\ScheduledVolumeBackup;
|
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Index extends Component
|
|
|
|
|
{
|
|
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
|
|
|
|
public Application $application;
|
|
|
|
|
|
|
|
|
|
public array $parameters;
|
|
|
|
|
|
2026-07-15 15:34:22 +00:00
|
|
|
public string $search = '';
|
|
|
|
|
|
2026-07-15 13:47:57 +00:00
|
|
|
protected $listeners = ['refreshVolumeBackups' => '$refresh'];
|
|
|
|
|
|
|
|
|
|
public function mount(): void
|
|
|
|
|
{
|
|
|
|
|
$this->application = $this->findApplication();
|
|
|
|
|
$this->authorize('view', $this->application);
|
|
|
|
|
$this->parameters = get_route_parameters();
|
2026-07-15 15:34:22 +00:00
|
|
|
$this->search = request()->string('search')->toString();
|
2026-07-15 13:47:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function render(): View
|
|
|
|
|
{
|
|
|
|
|
$backups = ScheduledVolumeBackup::query()
|
2026-07-15 15:34:22 +00:00
|
|
|
->with(['backupable', 'latestExecution'])
|
2026-07-15 13:47:57 +00:00
|
|
|
->withCount('executions')
|
2026-07-15 15:34:22 +00:00
|
|
|
->forApplication($this->application)
|
2026-07-15 13:47:57 +00:00
|
|
|
->latest()
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
return view('livewire.project.application.backup.index', ['backups' => $backups]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function findApplication(): Application
|
|
|
|
|
{
|
|
|
|
|
$project = currentTeam()->projects()
|
|
|
|
|
->where('uuid', request()->route('project_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
$environment = $project->environments()
|
|
|
|
|
->where('uuid', request()->route('environment_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
|
|
|
|
|
return $environment->applications()
|
|
|
|
|
->with('destination.server')
|
|
|
|
|
->where('uuid', request()->route('application_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
}
|
|
|
|
|
}
|