Refactor Show component to use firstOrFail method when retrieving server by UUID

This commit is contained in:
Andras Bacsai
2024-10-17 22:06:48 +02:00
parent 513c74a7e3
commit 9044c655b8

View File

@@ -22,10 +22,7 @@ class Show extends Component
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
try { try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail();
if (is_null($this->server)) {
return redirect()->route('server.index');
}
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }