<?php

require_once __DIR__ . '/../core/Controller.php';
require_once __DIR__ . '/../models/ContactoModel.php';

class ContactoController extends Controller
{
    public function index(): void
    {
        $this->render('contacto', [
            'title' => 'PetCare | Contacto'
        ]);
    }

    public function store(): void
    {
        if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
            $this->redirect('index.php?page=contacto');
        }

        $data = [
            'nombre' => trim($_POST['nombre'] ?? ''),
            'email' => trim($_POST['email'] ?? ''),
            'mensaje' => trim($_POST['mensaje'] ?? '')
        ];

        ContactoModel::create($data);
        $this->redirect('index.php?page=contacto');
    }
}
