2026-08-05 13:15:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Project\Service\VolumeBackup;
|
|
|
|
|
|
2026-08-07 22:12:56 +00:00
|
|
|
use App\Models\ScheduledDatabaseBackup;
|
2026-08-05 13:15:50 +00:00
|
|
|
use App\Models\ScheduledVolumeBackup;
|
|
|
|
|
use App\Models\Service;
|
2026-08-07 22:12:56 +00:00
|
|
|
use App\Models\ServiceDatabase;
|
2026-08-05 13:15:50 +00:00
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Index extends Component
|
|
|
|
|
{
|
|
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
|
|
|
|
public Service $service;
|
|
|
|
|
|
|
|
|
|
public array $parameters;
|
|
|
|
|
|
|
|
|
|
public string $search = '';
|
|
|
|
|
|
|
|
|
|
protected $listeners = ['refreshVolumeBackups' => '$refresh'];
|
|
|
|
|
|
|
|
|
|
public function mount(): void
|
|
|
|
|
{
|
|
|
|
|
$this->service = $this->findService();
|
|
|
|
|
$this->authorize('view', $this->service);
|
|
|
|
|
$this->parameters = get_route_parameters();
|
|
|
|
|
$this->search = request()->string('search')->toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function render(): View
|
|
|
|
|
{
|
2026-08-07 22:12:56 +00:00
|
|
|
$databaseTargets = $this->service->databases->filter(
|
|
|
|
|
fn (ServiceDatabase $database): bool => $database->isBackupSolutionAvailable(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$databaseBackups = ScheduledDatabaseBackup::query()
|
|
|
|
|
->with(['database', 'latest_log', 's3'])
|
|
|
|
|
->withCount('executions')
|
|
|
|
|
->where('database_type', (new ServiceDatabase)->getMorphClass())
|
|
|
|
|
->whereHasMorph('database', [ServiceDatabase::class], fn ($query) => $query->where('service_id', $this->service->id))
|
|
|
|
|
->latest()
|
|
|
|
|
->get();
|
|
|
|
|
|
2026-08-05 13:15:50 +00:00
|
|
|
$backups = ScheduledVolumeBackup::query()
|
2026-08-07 10:49:25 +00:00
|
|
|
->with(['backupable.resource', 'latestExecution', 's3'])
|
2026-08-05 13:15:50 +00:00
|
|
|
->withCount('executions')
|
|
|
|
|
->forService($this->service)
|
|
|
|
|
->latest()
|
|
|
|
|
->get();
|
|
|
|
|
|
2026-08-07 22:12:56 +00:00
|
|
|
return view('livewire.project.service.volume-backup.index', [
|
|
|
|
|
'backups' => $backups,
|
|
|
|
|
'databaseBackups' => $databaseBackups,
|
|
|
|
|
'databaseTargets' => $databaseTargets,
|
|
|
|
|
]);
|
2026-08-05 13:15:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function findService(): Service
|
|
|
|
|
{
|
|
|
|
|
$project = currentTeam()->projects()->where('uuid', request()->route('project_uuid'))->firstOrFail();
|
|
|
|
|
$environment = $project->environments()->where('uuid', request()->route('environment_uuid'))->firstOrFail();
|
|
|
|
|
|
|
|
|
|
return $environment->services()
|
|
|
|
|
->with(['server.settings', 'environment.project'])
|
|
|
|
|
->where('uuid', request()->route('service_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
}
|
|
|
|
|
}
|