From bce18056f335247e3fb03f62f1b6f20ff93204af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Elias=20Rios=20Nu=C3=B1ez?= Date: Mon, 1 Jun 2026 09:19:40 -0300 Subject: [PATCH] modelos y controladores --- app/Http/Controllers/ConsultaController.php | 61 +++++++++++++++++++++ app/Http/Controllers/Controller.php | 8 +++ app/Models/Consulta.php | 13 +++++ app/Models/User.php | 33 +++++++++++ 4 files changed, 115 insertions(+) create mode 100755 app/Http/Controllers/ConsultaController.php create mode 100755 app/Http/Controllers/Controller.php create mode 100755 app/Models/Consulta.php create mode 100755 app/Models/User.php diff --git a/app/Http/Controllers/ConsultaController.php b/app/Http/Controllers/ConsultaController.php new file mode 100755 index 0000000..e490e9a --- /dev/null +++ b/app/Http/Controllers/ConsultaController.php @@ -0,0 +1,61 @@ +get(); + return view('consultas.index', compact('consultas')); + } + + public function create() + { + return view('consultas.create'); + } + + public function store(Request $request) + { + $request->validate([ + 'asunto' => 'required|max:255', + 'categoria' => 'required', + 'mensaje' => 'required|min:10', + 'archivo_adjunto' => 'nullable|file|max:2048' + ]); + + $path = null; + if ($request->hasFile('archivo_adjunto')) { + $path = $request->file('archivo_adjunto')->store('adjuntos', 'public'); + } + + Consulta::create([ + 'asunto' => $request->asunto, + 'categoria' => $request->categoria, + 'mensaje' => $request->mensaje, + 'archivo_path' => $path + ]); + + return redirect('/consultas')->with('exito', '¡Tu consulta fue enviada!'); + } + + public function getTicketStatus($id) + { + $consulta = Consulta::find($id); + + if (!$consulta) { + return response()->json(['error' => 'Consulta no encontrada'], 404); + } + + return response()->json([ + 'id' => $consulta->id, + 'asunto' => $consulta->asunto, + 'estado_actual' => $consulta->estado, + 'ultima_actualizacion' => $consulta->updated_at + ]); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100755 index 0000000..8677cd5 --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,8 @@ + */ + use HasApiTo kens, HasFactory, Notifiable; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + } +}