2023-03-28 20:13:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-03-30 15:29:01 +00:00
|
|
|
use App\Models\Application;
|
|
|
|
use App\Models\Environment;
|
2023-03-28 20:13:08 +00:00
|
|
|
use Illuminate\Http\Request;
|
2023-03-29 10:27:02 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2023-03-28 20:13:08 +00:00
|
|
|
|
|
|
|
class ProjectController extends Controller
|
|
|
|
{
|
|
|
|
public function environments()
|
|
|
|
{
|
2023-03-30 17:50:27 +00:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first()->load(['environments']);
|
2023-03-28 20:13:08 +00:00
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
|
|
|
return view('project.environments', ['project' => $project]);
|
|
|
|
}
|
|
|
|
public function resources()
|
|
|
|
{
|
2023-03-30 17:50:27 +00:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-03-28 20:13:08 +00:00
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
2023-03-30 17:50:27 +00:00
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
2023-03-29 11:13:27 +00:00
|
|
|
return view('project.resources', ['project' => $project, 'environment' => $environment]);
|
2023-03-28 20:13:08 +00:00
|
|
|
}
|
|
|
|
public function application()
|
|
|
|
{
|
2023-03-30 17:50:27 +00:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
|
|
|
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
2023-03-28 20:13:08 +00:00
|
|
|
if (!$application) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
2023-03-30 15:29:01 +00:00
|
|
|
return view('project.application', ['application' => $application, 'deployments' => $application->deployments()]);
|
2023-03-28 20:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function deployment()
|
|
|
|
{
|
|
|
|
$deployment_uuid = request()->route('deployment_uuid');
|
|
|
|
|
2023-03-30 18:19:11 +00:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
|
|
|
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
2023-03-28 20:13:08 +00:00
|
|
|
if (!$application) {
|
|
|
|
return redirect()->route('home');
|
|
|
|
}
|
2023-03-29 10:27:02 +00:00
|
|
|
$activity = $application->get_deployment($deployment_uuid);
|
2023-03-30 15:29:01 +00:00
|
|
|
return view('project.deployment', ['activity' => $activity]);
|
2023-03-28 20:13:08 +00:00
|
|
|
}
|
|
|
|
}
|