2024-01-07 16:23:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Project\Database;
|
|
|
|
|
|
2026-05-20 19:04:43 +00:00
|
|
|
use Illuminate\Auth\Access\AuthorizationException;
|
2025-10-14 17:33:42 +02:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2026-05-20 19:04:43 +00:00
|
|
|
use Illuminate\Support\ItemNotFoundException;
|
2024-01-07 16:23:41 +01:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Configuration extends Component
|
|
|
|
|
{
|
2025-10-14 17:33:42 +02:00
|
|
|
use AuthorizesRequests;
|
2025-10-16 11:05:29 +02:00
|
|
|
|
2024-12-17 12:10:55 +01:00
|
|
|
public $currentRoute;
|
|
|
|
|
|
2024-01-07 16:23:41 +01:00
|
|
|
public $database;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-12-17 12:10:55 +01:00
|
|
|
public $project;
|
|
|
|
|
|
|
|
|
|
public $environment;
|
|
|
|
|
|
2024-04-12 12:44:49 +02:00
|
|
|
public function mount()
|
|
|
|
|
{
|
2025-08-23 18:50:35 +02:00
|
|
|
try {
|
|
|
|
|
$this->currentRoute = request()->route()->getName();
|
|
|
|
|
|
|
|
|
|
$project = currentTeam()
|
|
|
|
|
->projects()
|
2026-04-23 14:53:31 +05:30
|
|
|
->select('id', 'uuid', 'name', 'team_id')
|
2025-08-23 18:50:35 +02:00
|
|
|
->where('uuid', request()->route('project_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
$environment = $project->environments()
|
|
|
|
|
->select('id', 'name', 'project_id', 'uuid')
|
|
|
|
|
->where('uuid', request()->route('environment_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
$database = $environment->databases()
|
|
|
|
|
->where('uuid', request()->route('database_uuid'))
|
|
|
|
|
->firstOrFail();
|
|
|
|
|
|
2025-10-14 17:33:42 +02:00
|
|
|
$this->authorize('view', $database);
|
|
|
|
|
|
2025-08-23 18:50:35 +02:00
|
|
|
$this->database = $database;
|
|
|
|
|
$this->project = $project;
|
|
|
|
|
$this->environment = $environment;
|
|
|
|
|
if (str($this->database->status)->startsWith('running') && is_null($this->database->config_hash)) {
|
|
|
|
|
$this->database->isConfigurationChanged(true);
|
|
|
|
|
$this->dispatch('configurationChanged');
|
|
|
|
|
}
|
|
|
|
|
} catch (\Throwable $e) {
|
2026-05-20 19:04:43 +00:00
|
|
|
if ($e instanceof AuthorizationException) {
|
2025-08-23 18:50:35 +02:00
|
|
|
return redirect()->route('dashboard');
|
|
|
|
|
}
|
2026-05-20 19:04:43 +00:00
|
|
|
if ($e instanceof ItemNotFoundException) {
|
2025-08-23 18:50:35 +02:00
|
|
|
return redirect()->route('dashboard');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return handleError($e, $this);
|
2024-04-12 12:44:49 +02:00
|
|
|
}
|
2024-01-07 16:23:41 +01:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-07 16:23:41 +01:00
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.project.database.configuration');
|
|
|
|
|
}
|
|
|
|
|
}
|