An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(service): resolve team lookup via service relationship
Andras Bacsai61a54afe2be2
diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.phpindex 7b8b46812d..4bf78085e2 100644--- a/app/Models/ServiceApplication.php+++ b/app/Models/ServiceApplication.php@@ -88,7 +88,7 @@ class ServiceApplication extends BaseModelpublic function team(){- return data_get($this, 'environment.project.team');+ return data_get($this, 'service.environment.project.team');}public function workdir()diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.phpindex f6a39cfe48..7b0abe59e4 100644--- a/app/Models/ServiceDatabase.php+++ b/app/Models/ServiceDatabase.php@@ -124,7 +124,7 @@ class ServiceDatabase extends BaseModelpublic function team(){- return data_get($this, 'environment.project.team');+ return data_get($this, 'service.environment.project.team');}public function workdir()diff --git a/tests/Feature/ServiceDatabaseTeamTest.php b/tests/Feature/ServiceDatabaseTeamTest.phpnew file mode 100644index 0000000000..97bb0fd2a6--- /dev/null+++ b/tests/Feature/ServiceDatabaseTeamTest.php@@ -0,0 +1,77 @@+<?php++use App\Models\Environment;+use App\Models\Project;+use App\Models\Service;+use App\Models\ServiceApplication;+use App\Models\ServiceDatabase;+use App\Models\Team;+use Illuminate\Foundation\Testing\RefreshDatabase;++uses(RefreshDatabase::class);++it('returns the correct team through the service relationship chain', function () {+ $team = Team::factory()->create();++ $project = Project::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'Test Project',+ 'team_id' => $team->id,+ ]);++ $environment = Environment::create([+ 'name' => 'test-env-'.Illuminate\Support\Str::random(8),+ 'project_id' => $project->id,+ ]);++ $service = Service::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'supabase',+ 'environment_id' => $environment->id,+ 'destination_id' => 1,+ 'destination_type' => 'App\Models\StandaloneDocker',+ 'docker_compose_raw' => 'version: "3"',+ ]);++ $serviceDatabase = ServiceDatabase::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'supabase-db',+ 'service_id' => $service->id,+ ]);++ expect($serviceDatabase->team())->not->toBeNull()+ ->and($serviceDatabase->team()->id)->toBe($team->id);+});++it('returns the correct team for ServiceApplication through the service relationship chain', function () {+ $team = Team::factory()->create();++ $project = Project::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'Test Project',+ 'team_id' => $team->id,+ ]);++ $environment = Environment::create([+ 'name' => 'test-env-'.Illuminate\Support\Str::random(8),+ 'project_id' => $project->id,+ ]);++ $service = Service::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'supabase',+ 'environment_id' => $environment->id,+ 'destination_id' => 1,+ 'destination_type' => 'App\Models\StandaloneDocker',+ 'docker_compose_raw' => 'version: "3"',+ ]);++ $serviceApplication = ServiceApplication::create([+ 'uuid' => (string) Illuminate\Support\Str::uuid(),+ 'name' => 'supabase-studio',+ 'service_id' => $service->id,+ ]);++ expect($serviceApplication->team())->not->toBeNull()+ ->and($serviceApplication->team()->id)->toBe($team->id);+});