Fix null pointer exception in Index.php

This commit is contained in:
Andras Bacsai 2024-04-08 11:16:20 +02:00
parent 34aa4c6412
commit 2c41b5d4fb

View File

@ -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;