2024-03-07 10:35:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\Project;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class Resources extends Controller
|
|
|
|
{
|
|
|
|
public function resources(Request $request)
|
|
|
|
{
|
|
|
|
$teamId = get_team_id_from_token();
|
|
|
|
if (is_null($teamId)) {
|
|
|
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
|
|
|
}
|
|
|
|
$projects = Project::where('team_id', $teamId)->get();
|
|
|
|
$resources = collect();
|
|
|
|
$resources->push($projects->pluck('applications')->flatten());
|
|
|
|
$resources->push($projects->pluck('services')->flatten());
|
2024-03-07 10:37:56 +00:00
|
|
|
foreach (collect(DATABASE_TYPES) as $db) {
|
|
|
|
$resources->push($projects->pluck(str($db)->plural(2))->flatten());
|
|
|
|
}
|
2024-03-07 10:35:00 +00:00
|
|
|
$resources = $resources->flatten();
|
|
|
|
return response()->json($resources);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|