'required', ]; } public function mount ($model = null){ if (!empty($model)) { $hostGroup = HostGroup::find($model); $this->model = $model; $this->name = $hostGroup->name; $this->action = 'update'; } } public function store() { $validatedData = $this->validate(); HostGroup::create($validatedData); $this->dispatch('closeModal'); } public function update() { $validatedData = $this->validate(); $hostGroup = HostGroup::find($this->model); if (!empty($hostGroup)) { $hostGroup->update($validatedData); } $this->dispatch('closeModal'); } public function render() { return view('livewire.host-group.form'); } }