feat: api tokens + deploy webhook
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user