whereHas( 'servers', fn (Builder $query) => $query->where('server_id', $this->server->id) ); } protected static ?string $heading = ''; protected function getTableColumns(): array { return [ TextColumn::make('name') ->sortable() ->searchable(), TextColumn::make('user.name') ->sortable() ->searchable(), TextColumn::make('created_at') ->sortable(), ]; } public function getTable(): Table { return $this->table ->actions([ DeleteAction::make('delete') ->hiddenLabel() ->authorize(fn (SshKey $record) => auth()->user()->can('deleteServer', [SshKey::class, $this->server])) ->using(function (SshKey $record) { try { app(DeleteKeyFromServer::class)->delete($this->server, $record); } catch (Exception $e) { Notification::make() ->danger() ->title($e->getMessage()) ->send(); } $this->dispatch('$refresh'); }), ]); } }