lasthourcloud/app/Http/Controllers/ProjectController.php

69 lines
2.8 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
2023-03-30 15:29:01 +00:00
use App\Models\Application;
use App\Models\Environment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
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']);
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();
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]);
}
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();
if (!$application) {
return redirect()->route('home');
}
2023-03-30 15:29:01 +00:00
return view('project.application', ['application' => $application, 'deployments' => $application->deployments()]);
}
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();
if (!$application) {
return redirect()->route('home');
}
$activity = $application->get_deployment($deployment_uuid);
2023-03-30 15:29:01 +00:00
return view('project.deployment', ['activity' => $activity]);
}
}