From 4855af7e57bcee4aa2fe7ef9ee5ac445f4b59a0c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 20 Oct 2023 14:58:00 +0200 Subject: [PATCH] feat: start all kinds of things --- bootstrap/helpers/shared.php | 2 +- routes/api.php | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 123670dc5..3348ce1ae 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -463,7 +463,7 @@ function getResourceByUuid(string $uuid, ?int $teamId = null) { $resource = queryResourcesByUuid($uuid); if (!is_null($teamId)) { - if ($resource->environment->project->team_id === $teamId) { + if (!is_null($resource) && $resource->environment->project->team_id === $teamId) { return $resource; } return null; diff --git a/routes/api.php b/routes/api.php index 322582ace..77c000576 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,11 +1,9 @@ now(), ]); return response()->json(['message' => 'Database started.'], 200); + } else if ($type === 'App\Models\StandaloneRedis') { + StartRedis::run($resource); + $resource->update([ + 'started_at' => now(), + ]); + return response()->json(['message' => 'Database started.'], 200); + } else if ($type === 'App\Models\StandaloneMongodb') { + StartMongodb::run($resource); + $resource->update([ + 'started_at' => now(), + ]); + return response()->json(['message' => 'Database started.'], 200); + }else if ($type === 'App\Models\Service') { + StartService::run($resource); + return response()->json(['message' => 'Service started.'], 200); } } return response()->json(['error' => 'No resource found.'], 404);