2023-03-28 20:13:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-04-12 08:14:57 +00:00
|
|
|
use Spatie\Activitylog\Models\Activity;
|
2023-03-28 20:13:08 +00:00
|
|
|
|
|
|
|
class ProjectController extends Controller
|
|
|
|
{
|
|
|
|
public function environments()
|
|
|
|
{
|
2023-04-12 20:13:17 +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-04-12 20:13:17 +00:00
|
|
|
$project->load(['environments']);
|
2023-03-28 20:13:08 +00:00
|
|
|
return view('project.environments', ['project' => $project]);
|
|
|
|
}
|
2023-03-31 11:32:07 +00:00
|
|
|
|
2023-03-28 20:13:08 +00:00
|
|
|
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
|
|
|
}
|
2023-03-31 11:32:07 +00:00
|
|
|
|
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-04-12 08:14:57 +00:00
|
|
|
$activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
2023-03-31 11:32:07 +00:00
|
|
|
|
|
|
|
return view('project.deployment', [
|
2023-04-12 08:14:57 +00:00
|
|
|
'activity' => $activity,
|
2023-03-31 11:32:07 +00:00
|
|
|
'deployment_uuid' => $deployment_uuid,
|
|
|
|
]);
|
2023-03-28 20:13:08 +00:00
|
|
|
}
|
|
|
|
}
|