where('script_id', $this->script->id); } protected function applyDefaultSortingToTableQuery(Builder $query): Builder { return $query->latest('created_at'); } protected function getTableColumns(): array { return [ TextColumn::make('server') ->formatStateUsing(function (ScriptExecution $record) { return $record->getServer()?->name ?? 'Unknown'; }) ->url(function (ScriptExecution $record) { $server = $record->getServer(); return $server ? View::getUrl(['server' => $server]) : null; }) ->searchable() ->sortable(), TextColumn::make('created_at') ->label('Executed At') ->formatStateUsing(fn (ScriptExecution $record) => $record->created_at_by_timezone) ->searchable() ->sortable(), TextColumn::make('status') ->label('Status') ->badge() ->color(fn (ScriptExecution $record) => ScriptExecution::$statusColors[$record->status]) ->sortable(), ]; } public function table(Table $table): Table { return $table ->heading(null) ->query($this->getTableQuery()) ->columns($this->getTableColumns()) ->actions([ Action::make('logs') ->hiddenLabel() ->tooltip('Logs') ->icon('heroicon-o-eye') ->authorize(fn (ScriptExecution $record) => auth()->user()->can('view', $record->serverLog)) ->modalHeading('View Log') ->modalContent(function (ScriptExecution $record) { return view('components.console-view', [ 'slot' => $record->serverLog?->getContent(), 'attributes' => new ComponentAttributeBag, ]); }) ->modalSubmitAction(false) ->modalCancelActionLabel('Close'), ]); } }