forked from coollabsio/coolify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComposeDatabaseBackups.php
More file actions
61 lines (49 loc) · 2.23 KB
/
ComposeDatabaseBackups.php
File metadata and controls
61 lines (49 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace App\Livewire\Project\Application;
use App\Models\Application;
use App\Models\ServiceDatabase;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
class ComposeDatabaseBackups extends Component
{
use AuthorizesRequests;
public ?Application $application = null;
public ?ServiceDatabase $serviceDatabase = null;
public array $parameters;
public bool $isImportSupported = false;
public function mount()
{
try {
$this->parameters = get_route_parameters();
$this->application = Application::whereUuid($this->parameters['application_uuid'])->first();
if (! $this->application) {
return redirect()->route('dashboard');
}
$this->authorize('view', $this->application);
$this->serviceDatabase = $this->application->databases()->whereUuid($this->parameters['stack_service_uuid'])->first();
if (! $this->serviceDatabase) {
return redirect()->route('project.application.configuration', [
'project_uuid' => $this->parameters['project_uuid'],
'environment_uuid' => $this->parameters['environment_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
]);
}
if (! $this->serviceDatabase->isBackupSolutionAvailable() && ! $this->serviceDatabase->is_migrated) {
return redirect()->route('project.application.configuration', [
'project_uuid' => $this->parameters['project_uuid'],
'environment_uuid' => $this->parameters['environment_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
]);
}
$dbType = $this->serviceDatabase->databaseType();
$supportedTypes = ['mysql', 'mariadb', 'postgres', 'mongo'];
$this->isImportSupported = collect($supportedTypes)->contains(fn ($type) => str_contains($dbType, $type));
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function render()
{
return view('livewire.project.application.compose-database-backups');
}
}