diff --git a/app/Http/Controllers/FaultController.php b/app/Http/Controllers/FaultController.php new file mode 100644 index 0000000..09d7e98 --- /dev/null +++ b/app/Http/Controllers/FaultController.php @@ -0,0 +1,69 @@ + '#8cf5a8', + 'in_progress' => '#f3f58c', + 'resolved' => '#8cdaf5', + ]; + $modalData = session('modalData', null); + $isModalOpen = session('isModalOpen', false); + $updateStatus = session('updateStatus', false); + + return view('dashboard.faults', compact('faults', 'test', 'modalData', 'isModalOpen','updateStatus', 'colors')); + } + + public function openModal($id) + { + // Obtener los datos de la avería desde la base de datos + $fault = Fault::find($id); + + // Guardar el estado del modal y la información en la sesión + session([ + 'modalData' => $fault, + 'isModalOpen' => true + ]); + + return redirect()->route('dashboard.faults'); + } + + public function closeModal() + { + // Cerrar el modal al limpiar la sesión + session([ + 'isModalOpen' => false, + 'modalData' => null + ]); + + return redirect()->route('dashboard.faults'); + } + + public function updateStatus(Request $request, $id) + { + // Validar los datos del formulario + $request->validate([ + 'status' => 'required|in:open,in_progress,resolved' + ]); + + + $fault = Fault::find($id); + $fault->status = $request->status; + $fault->save(); + $this->closeModal(); + + return redirect()->route('dashboard.faults'); + } +} diff --git a/resources/views/dashboard/faults.blade.php b/resources/views/dashboard/faults.blade.php index c16e2e2..4ccf943 100644 --- a/resources/views/dashboard/faults.blade.php +++ b/resources/views/dashboard/faults.blade.php @@ -4,6 +4,8 @@ {{ __('Averías') }} + +