<?php
namespace App\Models;

use App\Core\Database;

class Message
{
    private $db;
    private $table = 'contact_messages';

    public function __construct()
    {
        $this->db = new Database();
    }

    public function save($data)
    {
        $sql = "INSERT INTO {$this->table} (name, email, subject, message, created_at) VALUES (:name, :email, :subject, :message, NOW())";
        return $this->db->insert($sql, [
            ':name' => $data['name'],
            ':email' => $data['email'],
            ':subject' => $data['subject'],
            ':message' => $data['message']
        ]);
    }
}
