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();
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return redirect()->route('server.index');
}
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail();
} catch (\Throwable $e) {
return handleError($e, $this);
}