get()->toArray(); foreach ($worldConfig as $config) { $this->realms[$config['realm_id']] = $config; } $this->selectedRealm = key($this->realms); } public function setRealm($realmId) { $this->selectedRealm = $realmId; $this->message = ''; $this->render(); } #[On('updateVariable')] public function updateVariable($variable, $value) { $this->message = ''; $text = __('custom.success_edit_world_config', ['variable' => $variable, 'oldValue' => $this->realms[$this->selectedRealm][$variable], 'newValue' => $value]); $worldConfig = WorldConfig::where('realm_id', $this->selectedRealm)->first(); $worldConfig->$variable = $value; $this->realms[$this->selectedRealm][$variable] = $value; $worldConfig->save(); $this->message = $text; $this->render(); } public function reloadConfig() { $this->message = ''; $text = __('custom.success_reload_config', ['realm' => config('customs.realms')[$this->selectedRealm]['name']]); $pendingCommand = PendingCommand::create([ 'realm_id' => $this->selectedRealm, 'command' => 'reload config', 'run_at_time' => 0 ]); if ($pendingCommand) { $this->message = $text; } } public function render() { return view('livewire.config'); } }