loadVariables(); } public function loadVariables(): void { $names = [ 'innodb_buffer_pool_size', 'max_connections', 'tmp_table_size', 'max_heap_table_size', 'innodb_log_file_size', 'innodb_flush_log_at_trx_commit', ]; try { $placeholders = implode("','", $names); $rows = DB::connection('mysql')->select("SHOW VARIABLES WHERE Variable_name IN ('$placeholders')"); $this->variables = collect($rows)->map(function ($row) { return [ 'name' => $row->Variable_name, 'value' => $row->Value, ]; })->toArray(); } catch (\Exception $e) { $this->variables = []; Notification::make() ->title(__('Unable to load MySQL variables')) ->body($e->getMessage()) ->warning() ->send(); } $this->resetTable(); } public function table(Table $table): Table { return $table ->records(fn () => $this->variables) ->columns([ TextColumn::make('name') ->label(__('Variable')) ->fontFamily('mono'), TextColumn::make('value') ->label(__('Current Value')) ->fontFamily('mono'), ]) ->recordActions([ Action::make('update') ->label(__('Update')) ->icon('heroicon-o-pencil-square') ->form([ TextInput::make('value') ->label(__('New Value')) ->required(), ]) ->action(function (array $record, array $data): void { try { DB::connection('mysql')->statement('SET GLOBAL '.$record['name'].' = ?', [$data['value']]); try { $agent = new AgentClient; $agent->databasePersistTuning($record['name'], (string) $data['value']); Notification::make() ->title(__('Variable updated')) ->success() ->send(); } catch (\Exception $e) { Notification::make() ->title(__('Variable updated, but not persisted')) ->body($e->getMessage()) ->warning() ->send(); } } catch (\Exception $e) { Notification::make()->title(__('Update failed'))->body($e->getMessage())->danger()->send(); } $this->loadVariables(); }), ]) ->emptyStateHeading(__('No variables found')) ->emptyStateDescription(__('Database variables could not be loaded.')); } }