feat: api tokens + deploy webhook

This commit is contained in:
Andras Bacsai
2023-10-20 14:51:01 +02:00
parent c19c13b4e2
commit a664174c02
13 changed files with 175 additions and 25 deletions

View File

@@ -1,7 +1,12 @@
<?php
use App\Models\Application;
use App\Models\InstanceSettings;
use App\Models\Server;
use App\Models\Service;
use App\Models\StandaloneMongodb;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use App\Models\Team;
use App\Models\User;
use App\Notifications\Channels\DiscordChannel;
@@ -453,3 +458,31 @@ function getServiceTemplates()
}
return $services;
}
function getResourceByUuid(string $uuid, ?int $teamId = null)
{
$resource = queryResourcesByUuid($uuid);
if (!is_null($teamId)) {
if ($resource->environment->project->team_id === $teamId) {
return $resource;
}
return null;
} else {
return $resource;
}
}
function queryResourcesByUuid(string $uuid)
{
$resource = null;
$application = Application::whereUuid($uuid)->first();
if ($application) return $application;
$service = Service::whereUuid($uuid)->first();
if ($service) return $service;
$postgresql = StandalonePostgresql::whereUuid($uuid)->first();
if ($postgresql) return $postgresql;
$redis = StandaloneRedis::whereUuid($uuid)->first();
if ($redis) return $redis;
$mongodb = StandaloneMongodb::whereUuid($uuid)->first();
if ($mongodb) return $mongodb;
return $resource;
}