2023-03-28 22:13:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-05-22 15:47:40 +02:00
|
|
|
use App\Models\Project;
|
2023-07-26 13:23:47 +02:00
|
|
|
use App\Models\Server;
|
2023-03-28 22:13:08 +02:00
|
|
|
|
|
|
|
class ProjectController extends Controller
|
|
|
|
{
|
2023-05-22 15:47:40 +02:00
|
|
|
public function all()
|
2023-03-28 22:13:08 +02:00
|
|
|
{
|
2023-07-26 13:23:47 +02:00
|
|
|
return view('projects', [
|
|
|
|
'projects' => Project::ownedByCurrentTeam()->get(),
|
|
|
|
'servers' => Server::ownedByCurrentTeam()->count(),
|
|
|
|
]);
|
2023-05-22 15:47:40 +02:00
|
|
|
}
|
|
|
|
|
2023-06-22 09:33:26 +02:00
|
|
|
public function edit()
|
|
|
|
{
|
|
|
|
$projectUuid = request()->route('project_uuid');
|
|
|
|
$teamId = session('currentTeam')->id;
|
|
|
|
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
return view('project.edit', ['project' => $project]);
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-05-22 15:47:40 +02:00
|
|
|
public function show()
|
|
|
|
{
|
2023-06-15 09:15:41 +02:00
|
|
|
$projectUuid = request()->route('project_uuid');
|
|
|
|
$teamId = session('currentTeam')->id;
|
2023-05-22 15:47:40 +02:00
|
|
|
|
2023-06-15 09:15:41 +02:00
|
|
|
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->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-05-22 15:47:40 +02:00
|
|
|
return view('project.show', ['project' => $project]);
|
2023-03-28 22:13:08 +02:00
|
|
|
}
|
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-08-08 11:51:36 +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
|
|
|
}
|
|
|
|
}
|