lasthourcloud/app/Http/Controllers/ApplicationController.php

88 lines
3.8 KiB
PHP
Raw Normal View History

2023-04-19 10:42:15 +00:00
<?php
namespace App\Http\Controllers;
2023-05-30 13:52:17 +00:00
use App\Models\ApplicationDeploymentQueue;
2023-06-07 13:08:35 +00:00
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
2023-04-19 10:42:15 +00:00
class ApplicationController extends Controller
{
2023-06-07 13:08:35 +00:00
use AuthorizesRequests, ValidatesRequests;
2023-04-19 10:42:15 +00:00
public function configuration()
{
2023-08-22 15:44:49 +00:00
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2023-04-19 10:42:15 +00:00
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-30 13:52:17 +00:00
return view('project.application.configuration', ['application' => $application]);
2023-04-19 10:42:15 +00:00
}
2023-04-19 10:42:15 +00:00
public function deployments()
{
2023-08-22 15:44:49 +00:00
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2023-04-19 10:42:15 +00:00
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
}
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 40);
2023-06-30 09:42:59 +00:00
return view('project.application.deployments', ['application' => $application, 'deployments' => $deployments, 'deployments_count' => $count]);
2023-04-19 10:42:15 +00:00
}
public function deployment()
{
2023-06-15 07:15:41 +00:00
$deploymentUuid = request()->route('deployment_uuid');
2023-04-19 10:42:15 +00:00
2023-08-22 15:44:49 +00:00
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2023-04-19 10:42:15 +00:00
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-06-30 13:57:40 +00:00
// $activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first();
// if (!$activity) {
// return redirect()->route('project.application.deployments', [
// 'project_uuid' => $project->uuid,
// 'environment_name' => $environment->name,
// 'application_uuid' => $application->uuid,
// ]);
// }
$application_deployment_queue = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
if (!$application_deployment_queue) {
2023-05-30 13:52:17 +00:00
return redirect()->route('project.application.deployments', [
'project_uuid' => $project->uuid,
'environment_name' => $environment->name,
'application_uuid' => $application->uuid,
]);
}
2023-04-25 09:01:56 +00:00
return view('project.application.deployment', [
2023-04-19 10:42:15 +00:00
'application' => $application,
2023-06-30 13:57:40 +00:00
// 'activity' => $activity,
'application_deployment_queue' => $application_deployment_queue,
2023-06-15 07:15:41 +00:00
'deployment_uuid' => $deploymentUuid,
2023-04-19 10:42:15 +00:00
]);
}
2023-08-07 20:14:21 +00:00
}