validate([ 'ip' => ['required', 'string', 'max:64', 'regex:/^[a-zA-Z0-9.\-]+$/'], 'name' => ['nullable', 'string', 'max:100'], 'roomId' => ['nullable', 'integer', 'exists:rooms,id'], ]); $this->error = null; try { $device = app(ShellyLocalOnboarder::class)->onboard(trim($this->ip), $this->name ?: null, $this->roomId ?: null); } catch (\Throwable) { $this->error = __('devices.add_unreachable'); return; } $this->closeModal(); return redirect()->route('devices.show', $device); } public function render() { return view('livewire.modals.add-device', [ 'rooms' => Room::orderBy('sort')->orderBy('name')->get(), ]); } }