2023-08-07 18:46:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
|
|
|
|
|
class DatabaseController extends Controller
|
|
|
|
{
|
|
|
|
use AuthorizesRequests, ValidatesRequests;
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-08-07 18:46:40 +02:00
|
|
|
public function configuration()
|
|
|
|
{
|
2023-08-22 17:44:49 +02:00
|
|
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-08-07 18:46:40 +02:00
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$database = $environment->databases->where('uuid', request()->route('database_uuid'))->first();
|
|
|
|
if (!$database) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
return view('project.database.configuration', ['database' => $database]);
|
|
|
|
}
|
2023-08-09 16:47:24 +02:00
|
|
|
|
2023-08-11 10:42:57 +02:00
|
|
|
public function executions()
|
2023-08-10 15:52:54 +02:00
|
|
|
{
|
|
|
|
$backup_uuid = request()->route('backup_uuid');
|
2023-08-22 17:44:49 +02:00
|
|
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-08-10 15:52:54 +02:00
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$database = $environment->databases->where('uuid', request()->route('database_uuid'))->first();
|
|
|
|
if (!$database) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
|
|
|
|
if (!$backup) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
2023-08-11 10:42:57 +02:00
|
|
|
$executions = collect($backup->executions)->sortByDesc('created_at');
|
2023-08-11 16:13:53 +02:00
|
|
|
return view('project.database.backups.executions', [
|
|
|
|
'database' => $database,
|
|
|
|
'backup' => $backup,
|
|
|
|
'executions' => $executions,
|
2023-08-22 17:44:49 +02:00
|
|
|
's3s' => currentTeam()->s3s,
|
2023-08-11 16:13:53 +02:00
|
|
|
]);
|
2023-08-10 15:52:54 +02:00
|
|
|
}
|
|
|
|
|
2023-08-09 16:47:24 +02:00
|
|
|
public function backups()
|
|
|
|
{
|
2023-08-22 17:44:49 +02:00
|
|
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-08-09 16:47:24 +02:00
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$database = $environment->databases->where('uuid', request()->route('database_uuid'))->first();
|
|
|
|
if (!$database) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
2023-08-11 16:13:53 +02:00
|
|
|
return view('project.database.backups.all', [
|
|
|
|
'database' => $database,
|
2023-08-22 17:44:49 +02:00
|
|
|
's3s' => currentTeam()->s3s,
|
2023-08-11 16:13:53 +02:00
|
|
|
]);
|
2023-08-09 16:47:24 +02:00
|
|
|
}
|
2023-08-07 22:14:21 +02:00
|
|
|
}
|