<?php
require_once __DIR__ . '/db.php'; // ✅ Keeps current PDO logic

class Message {
    private $conn;

    public function __construct() {
        global $pdo; // ✅ Access the global $pdo object
        $this->conn = $pdo;
    }

    public function addMessage($data) {
        $stmt = $this->conn->prepare("
            INSERT INTO messegedetails (type, title, mobile, subheading, image, device_id)
            VALUES (?, ?, ?, ?, ?, ?)
        ");
        $stmt->execute([
            $data['type'], $data['title'], $data['mobile'],
            $data['subheading'], $data['image'], $data['device_id']
        ]);
        return $this->conn->lastInsertId();
    }
}
