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
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Spatie\Activitylog\Models\Activity;
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
$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-30 13:52:17 +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-05-24 12:26:50 +00:00
|
|
|
return view('project.application.deployments', ['application' => $application]);
|
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
|
|
|
|
|
|
|
$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-06-15 07:15:41 +00:00
|
|
|
$activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first();
|
2023-05-03 06:53:00 +00:00
|
|
|
if (!$activity) {
|
|
|
|
return redirect()->route('project.application.deployments', [
|
|
|
|
'project_uuid' => $project->uuid,
|
|
|
|
'environment_name' => $environment->name,
|
|
|
|
'application_uuid' => $application->uuid,
|
|
|
|
]);
|
|
|
|
}
|
2023-06-15 07:15:41 +00:00
|
|
|
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
|
2023-05-30 13:52:17 +00:00
|
|
|
if (!$deployment) {
|
|
|
|
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,
|
|
|
|
'activity' => $activity,
|
2023-05-30 13:52:17 +00:00
|
|
|
'deployment' => $deployment,
|
2023-06-15 07:15:41 +00:00
|
|
|
'deployment_uuid' => $deploymentUuid,
|
2023-04-19 10:42:15 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|