authorize('datacenters.manage'); // modals are reachable without the route middleware $dc = Datacenter::query()->where('uuid', $uuid)->firstOrFail(); $this->uuid = $uuid; $this->code = $dc->code; $this->name = $dc->name; $this->location = (string) $dc->location; } public function save() { $this->authorize('datacenters.manage'); // Validate the country against the configured list so add + edit stay in sync. $data = $this->validate([ 'name' => 'required|string|max:255', 'location' => 'nullable|in:'.implode(',', array_keys((array) config('countries'))), ]); Datacenter::query()->where('uuid', $this->uuid)->update([ 'name' => $data['name'], 'location' => $data['location'] ?: null, ]); $this->dispatch('notify', message: __('datacenters.updated')); return $this->redirectRoute('admin.datacenters', navigate: true); } public function render() { return view('livewire.admin.edit-datacenter', [ 'countries' => config('countries'), ]); } }