<?php

namespace Core\App\Models;

use PDO;

class NotificationModel
{
    protected PDO $db;

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

    /**
     * Create notification
     */
    public function create(array $data): void
    {
        $stmt = $this->db->prepare("
            INSERT INTO notifications
                (type, title, message, data, created_at)
            VALUES
                (:type, :title, :message, :data, NOW())
        ");

        $stmt->execute([
            ':type'    => $data['type']    ?? 'system',
            ':title'   => $data['title']   ?? '',
            ':message' => $data['message'] ?? '',
            ':data'    => $data['data']    ?? null,
        ]);
    }
}
