lasthourcloud/app/Http/Controllers/Api/Project.php

45 lines
1.4 KiB
PHP
Raw Normal View History

<?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
{
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();
}
$projects = ModelsProject::whereTeamId($teamId)->select('id', 'name', 'uuid')->get();
2024-06-10 20:43:34 +00:00
return response()->json($projects);
}
2024-06-10 20:43:34 +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();
}
$project = ModelsProject::whereTeamId($teamId)->whereUuid(request()->uuid)->first()->load(['environments']);
2024-06-10 20:43:34 +00:00
return response()->json($project);
}
2024-06-10 20:43:34 +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();
}
$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
return response()->json($environment);
}
}