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', + ]; + } +}