Refactor Show component to initialize server and remove unused code

This commit is contained in:
Andras Bacsai
2024-10-17 21:48:43 +02:00
parent a6259d8a52
commit df4e4c2b4e

View File

@@ -2,28 +2,22 @@
namespace App\Livewire\Server; namespace App\Livewire\Server;
use App\Livewire\BaseComponent;
use App\Models\Server; use App\Models\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
class Show extends Component class Show extends BaseComponent
{ {
use AuthorizesRequests; use AuthorizesRequests;
public ?Server $server = null; public Server $server;
public $parameters = [];
protected $listeners = ['refreshServerShow']; protected $listeners = ['refreshServerShow'];
public function mount() public function mount()
{ {
$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);
} }