From 2c41b5d4fbe175b6c951345c74c345ca45b3c77b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 8 Apr 2024 11:16:20 +0200 Subject: [PATCH] Fix null pointer exception in Index.php --- app/Livewire/Project/Service/Index.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Project/Service/Index.php b/app/Livewire/Project/Service/Index.php index ede42c2c7..fe335afb1 100644 --- a/app/Livewire/Project/Service/Index.php +++ b/app/Livewire/Project/Service/Index.php @@ -10,7 +10,7 @@ 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 @@ public function mount() $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;