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