lasthourcloud/app/Http/Controllers/ApplicationController.php

68 lines
2.8 KiB
PHP
Raw Normal View History

2023-04-19 10:42:15 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Spatie\Activitylog\Models\Activity;
class ApplicationController extends Controller
{
public function configuration()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
2023-04-25 09:01:56 +00:00
return view('project.application.configuration', ['application' => $application]);
2023-04-19 10:42:15 +00:00
}
public function deployments()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
2023-04-25 09:01:56 +00:00
return view('project.application.deployments', ['application' => $application, 'deployments' => $application->deployments()]);
2023-04-19 10:42:15 +00:00
}
public function deployment()
{
$deployment_uuid = request()->route('deployment_uuid');
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
2023-04-25 12:43:35 +00:00
return redirect()->route('dashboard');
2023-04-19 10:42:15 +00:00
}
2023-05-03 06:51:03 +00:00
$activity = Activity::where('properties->type_uuid', '=', $deployment_uuid)->first();
2023-04-19 10:42:15 +00:00
2023-04-25 09:01:56 +00:00
return view('project.application.deployment', [
2023-04-19 10:42:15 +00:00
'application' => $application,
'activity' => $activity,
'deployment_uuid' => $deployment_uuid,
]);
}
}