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