diff --git a/app/Http/Livewire/Server/ServerCard.php b/app/Http/Livewire/Server/ServerCard.php index 582b92c30..d159e60f8 100644 --- a/app/Http/Livewire/Server/ServerCard.php +++ b/app/Http/Livewire/Server/ServerCard.php @@ -17,7 +17,7 @@ public function mount(Server $server) public function reactivate() { - Artisan::call('ping:server '.$this->server->uuid.' true'); + Artisan::call('server:ping '.$this->server->uuid.' true'); $this->server->active = true; $this->server->save(); $this->emit('serverUpdated'); diff --git a/app/Http/Livewire/Server/ServerCardList.php b/app/Http/Livewire/Server/ServerCardList.php index b2a01e934..2d95feceb 100644 --- a/app/Http/Livewire/Server/ServerCardList.php +++ b/app/Http/Livewire/Server/ServerCardList.php @@ -9,28 +9,42 @@ class ServerCardList extends Component { public $servers; + public $my_servers; + + public $user; + protected $listeners = [ 'serverUpdated' => 'update', ]; public function mount() { - $this->servers = Server::orderBy('official', 'desc') - ->orderBy('last_online_at', 'desc') - ->orderBy('ping', 'asc') - ->get(); + $this->loadData(); } public function update() { - $this->servers = Server::orderBy('official', 'desc') - ->orderBy('last_online_at', 'desc') - ->orderBy('ping', 'asc') - ->get(); + $this->loadData(); } public function render() { return view('livewire.server.server-card-list'); } + + private function loadData(): void + { + $this->user = auth()->user() ?? null; + $this->servers = isset($this->user) ? Server::where('user_id', '!=', $this->user->id) + ->where('active', true) + ->orderBy('official', 'desc') + ->orderBy('last_online_at', 'desc') + ->orderBy('ping', 'asc') + ->get() : Server::orderBy('official', 'desc') + ->where('active', true) + ->orderBy('last_online_at', 'desc') + ->orderBy('ping', 'asc') + ->get(); + $this->my_servers = isset($this->user) ? Server::where('user_id', $this->user->id)->get() : collect(); + } } diff --git a/resources/views/livewire/server/server-card-list.blade.php b/resources/views/livewire/server/server-card-list.blade.php index abca12ac9..393998dfc 100644 --- a/resources/views/livewire/server/server-card-list.blade.php +++ b/resources/views/livewire/server/server-card-list.blade.php @@ -1,10 +1,17 @@
{{ __('All server statuses are updated every hour.') }}
-{{ __('All server statuses are updated every hour.') }}
+ @if($this->my_servers->count() > 0) +