2023-03-28 22:13:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-04-12 10:14:57 +02:00
|
|
|
use Spatie\Activitylog\Models\Activity;
|
2023-03-28 22:13:08 +02:00
|
|
|
|
|
|
|
class ProjectController extends Controller
|
|
|
|
{
|
|
|
|
public function environments()
|
|
|
|
{
|
2023-04-12 22:13:17 +02:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-03-28 22:13:08 +02:00
|
|
|
if (!$project) {
|
2023-04-25 14:43:35 +02:00
|
|
|
return redirect()->route('dashboard');
|
2023-03-28 22:13:08 +02:00
|
|
|
}
|
2023-04-12 22:13:17 +02:00
|
|
|
$project->load(['environments']);
|
2023-04-19 15:38:59 +02:00
|
|
|
if (count($project->environments) == 1) {
|
|
|
|
return redirect()->route('project.resources', ['project_uuid' => $project->uuid, 'environment_name' => $project->environments->first()->name]);
|
|
|
|
}
|
2023-03-28 22:13:08 +02:00
|
|
|
return view('project.environments', ['project' => $project]);
|
|
|
|
}
|
2023-03-31 12:32:07 +01:00
|
|
|
|
2023-05-11 15:20:02 +02:00
|
|
|
public function new()
|
2023-04-26 13:25:41 +02:00
|
|
|
{
|
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
|
|
|
if (!$environment) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
2023-05-11 15:20:02 +02:00
|
|
|
|
|
|
|
$type = request()->query('type');
|
|
|
|
|
|
|
|
return view('project.new', [
|
|
|
|
'type' => $type
|
|
|
|
]);
|
2023-04-26 13:25:41 +02:00
|
|
|
}
|
2023-03-28 22:13:08 +02:00
|
|
|
public function resources()
|
|
|
|
{
|
2023-03-30 19:50:27 +02:00
|
|
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
2023-03-28 22:13:08 +02:00
|
|
|
if (!$project) {
|
2023-04-25 14:43:35 +02:00
|
|
|
return redirect()->route('dashboard');
|
2023-03-28 22:13:08 +02:00
|
|
|
}
|
2023-03-30 19:50:27 +02:00
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
|
|
|
if (!$environment) {
|
2023-04-25 14:43:35 +02:00
|
|
|
return redirect()->route('dashboard');
|
2023-03-30 19:50:27 +02:00
|
|
|
}
|
2023-05-16 15:27:47 +02:00
|
|
|
return view('project.resources', [
|
|
|
|
'project' => $project,
|
|
|
|
'environment' => $environment
|
|
|
|
]);
|
2023-03-28 22:13:08 +02:00
|
|
|
}
|
|
|
|
}
|