From df4e4c2b4ed7681603ff5560e7ca4f8687e3aaa8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 17 Oct 2024 21:48:43 +0200 Subject: [PATCH] Refactor Show component to initialize server and remove unused code --- app/Livewire/Server/Show.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.php index a5e94a19a..0e07ec0a1 100644 --- a/app/Livewire/Server/Show.php +++ b/app/Livewire/Server/Show.php @@ -2,28 +2,22 @@ namespace App\Livewire\Server; +use App\Livewire\BaseComponent; use App\Models\Server; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Livewire\Component; -class Show extends Component +class Show extends BaseComponent { use AuthorizesRequests; - public ?Server $server = null; - - public $parameters = []; + public Server $server; protected $listeners = ['refreshServerShow']; public function mount() { - $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); }