2024-02-16 20:56:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\Project as ModelsProject;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
2024-02-27 07:03:42 +00:00
|
|
|
class Project extends Controller
|
2024-02-16 20:56:38 +00:00
|
|
|
{
|
|
|
|
public function projects(Request $request)
|
|
|
|
{
|
|
|
|
$teamId = get_team_id_from_token();
|
|
|
|
if (is_null($teamId)) {
|
2024-03-07 11:27:23 +00:00
|
|
|
return invalid_token();
|
2024-02-16 20:56:38 +00:00
|
|
|
}
|
|
|
|
$projects = ModelsProject::whereTeamId($teamId)->select('id', 'name', 'uuid')->get();
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-16 20:56:38 +00:00
|
|
|
return response()->json($projects);
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-16 20:56:38 +00:00
|
|
|
public function project_by_uuid(Request $request)
|
|
|
|
{
|
|
|
|
$teamId = get_team_id_from_token();
|
|
|
|
if (is_null($teamId)) {
|
2024-03-07 11:27:23 +00:00
|
|
|
return invalid_token();
|
2024-02-16 20:56:38 +00:00
|
|
|
}
|
|
|
|
$project = ModelsProject::whereTeamId($teamId)->whereUuid(request()->uuid)->first()->load(['environments']);
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-16 20:56:38 +00:00
|
|
|
return response()->json($project);
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-16 20:56:38 +00:00
|
|
|
public function environment_details(Request $request)
|
|
|
|
{
|
|
|
|
$teamId = get_team_id_from_token();
|
|
|
|
if (is_null($teamId)) {
|
2024-03-07 11:27:23 +00:00
|
|
|
return invalid_token();
|
2024-02-16 20:56:38 +00:00
|
|
|
}
|
|
|
|
$project = ModelsProject::whereTeamId($teamId)->whereUuid(request()->uuid)->first();
|
|
|
|
$environment = $project->environments()->whereName(request()->environment_name)->first()->load(['applications', 'postgresqls', 'redis', 'mongodbs', 'mysqls', 'mariadbs', 'services']);
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-16 20:56:38 +00:00
|
|
|
return response()->json($environment);
|
|
|
|
}
|
|
|
|
}
|