lasthourcloud/app/Livewire/Project/Database/Backup/Execution.php

49 lines
1.5 KiB
PHP
Raw Normal View History

2024-01-07 15:23:41 +00:00
<?php
namespace App\Livewire\Project\Database\Backup;
2024-05-24 15:20:20 +00:00
use App\Models\ScheduledDatabaseBackup;
2024-01-07 15:23:41 +00:00
use Livewire\Component;
class Execution extends Component
{
public $database;
2024-06-10 20:43:34 +00:00
2024-05-24 15:20:20 +00:00
public ?ScheduledDatabaseBackup $backup;
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
public $executions;
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
public $s3s;
2024-06-10 20:43:34 +00:00
public function mount()
{
2024-01-07 15:23:41 +00:00
$backup_uuid = request()->route('backup_uuid');
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2024-06-10 20:43:34 +00:00
if (! $project) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
2024-06-10 20:43:34 +00:00
if (! $environment) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
2024-06-10 20:43:34 +00:00
if (! $database) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
2024-06-10 20:43:34 +00:00
if (! $backup) {
2024-01-07 15:23:41 +00:00
return redirect()->route('dashboard');
}
$executions = collect($backup->executions)->sortByDesc('created_at');
$this->database = $database;
$this->backup = $backup;
$this->executions = $executions;
$this->s3s = currentTeam()->s3s;
}
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
public function render()
{
return view('livewire.project.database.backup.execution');
}
}