Skip to content

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.

Fix null pointer exception in Index.php

Andras Bacsai2c41b5d4fbe1
diff --git a/app/Livewire/Project/Service/Index.php b/app/Livewire/Project/Service/Index.php
index ede42c2c71..fe335afb1b 100644
--- a/app/Livewire/Project/Service/Index.php
+++ b/app/Livewire/Project/Service/Index.php
@@ -10,7 +10,7 @@ use Livewire\Component;
class Index extends Component
{
- public Service $service;
+ public ?Service $service = null;
public ?ServiceApplication $serviceApplication = null;
public ?ServiceDatabase $serviceDatabase = null;
public array $parameters;
@@ -26,7 +26,10 @@ class Index extends Component
$this->services = collect([]);
$this->parameters = get_route_parameters();
$this->query = request()->query();
- $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
+ $this->service = Service::whereUuid($this->parameters['service_uuid'])->first();
+ if (!$this->service) {
+ return redirect()->route('dashboard');
+ }
$service = $this->service->applications()->whereUuid($this->parameters['stack_service_uuid'])->first();
if ($service) {
$this->serviceApplication = $service;