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

66 lines
2.0 KiB
PHP
Raw Normal View History

2024-03-07 11:01:21 +00:00
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class Team extends Controller
{
public function teams(Request $request)
{
$teamId = get_team_id_from_token();
if (is_null($teamId)) {
2024-03-07 11:27:23 +00:00
return invalid_token();
2024-03-07 11:01:21 +00:00
}
$teams = auth()->user()->teams;
return response()->json($teams);
}
public function team_by_id(Request $request)
{
$id = $request->id;
$teamId = get_team_id_from_token();
if (is_null($teamId)) {
2024-03-07 11:27:23 +00:00
return invalid_token();
2024-03-07 11:01:21 +00:00
}
$teams = auth()->user()->teams;
$team = $teams->where('id', $id)->first();
if (is_null($team)) {
2024-03-27 10:07:29 +00:00
return response()->json(['error' => 'Team not found.', "docs" => "https://coolify.io/docs/api-reference/get-team-by-teamid"], 404);
2024-03-07 11:01:21 +00:00
}
return response()->json($team);
}
public function members_by_id(Request $request)
{
$id = $request->id;
$teamId = get_team_id_from_token();
if (is_null($teamId)) {
2024-03-07 11:27:23 +00:00
return invalid_token();
2024-03-07 11:01:21 +00:00
}
$teams = auth()->user()->teams;
$team = $teams->where('id', $id)->first();
if (is_null($team)) {
2024-03-27 10:07:29 +00:00
return response()->json(['error' => 'Team not found.', "docs" => "https://coolify.io/docs/api-reference/get-team-by-teamid-members"], 404);
2024-03-07 11:01:21 +00:00
}
return response()->json($team->members);
}
public function current_team(Request $request)
{
$teamId = get_team_id_from_token();
if (is_null($teamId)) {
2024-03-07 11:27:23 +00:00
return invalid_token();
2024-03-07 11:01:21 +00:00
}
$team = auth()->user()->currentTeam();
return response()->json($team);
}
public function current_team_members(Request $request)
{
2024-03-07 11:01:21 +00:00
$teamId = get_team_id_from_token();
if (is_null($teamId)) {
2024-03-07 11:27:23 +00:00
return invalid_token();
2024-03-07 11:01:21 +00:00
}
$team = auth()->user()->currentTeam();
return response()->json($team->members);
}
}