'required', 'start_at' => 'required', 'finished_at' => 'required', ]; } public function mount ($model = null){ if (!empty($model)) { $maintenance-history = MaintenanceHistory::find($model); $this->model = $model; $this->maintenance_id = $maintenance-history->maintenance_id; $this->start_at = $maintenance-history->start_at; $this->finished_at = $maintenance-history->finished_at; $this->action = 'update'; } } public function store() { $validatedData = $this->validate(); MaintenanceHistory::create($validatedData); $this->dispatch('closeModal'); } public function update() { $validatedData = $this->validate(); $maintenance-history = MaintenanceHistory::find($this->model); if (!empty($maintenance-history)) { $maintenance-history->update($validatedData); } $this->dispatch('closeModal'); } public function render() { return view('livewire.components.maintenance-history.form'); } }