2024-01-07 15:23:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Livewire\Project\Database\Backup;
|
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Index extends Component
|
|
|
|
{
|
|
|
|
public $database;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-04-10 13:00:46 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2024-01-07 15:23:41 +00:00
|
|
|
$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');
|
|
|
|
}
|
2024-04-10 13:00:46 +00:00
|
|
|
// No backups
|
|
|
|
if (
|
|
|
|
$database->getMorphClass() === 'App\Models\StandaloneRedis' ||
|
|
|
|
$database->getMorphClass() === 'App\Models\StandaloneKeydb' ||
|
2024-06-10 20:43:34 +00:00
|
|
|
$database->getMorphClass() === 'App\Models\StandaloneDragonfly' ||
|
2024-04-10 13:00:46 +00:00
|
|
|
$database->getMorphClass() === 'App\Models\StandaloneClickhouse'
|
|
|
|
) {
|
2024-01-07 15:23:41 +00:00
|
|
|
return redirect()->route('project.database.configuration', [
|
|
|
|
'project_uuid' => $project->uuid,
|
|
|
|
'environment_name' => $environment->name,
|
|
|
|
'database_uuid' => $database->uuid,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
$this->database = $database;
|
|
|
|
}
|
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.index');
|
|
|
|
}
|
|
|
|
}
|