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