<?php

namespace FleekDash\Models;

defined('ABSPATH') || exit;

class NotificationNote extends BaseModel
{
    protected $table = 'fleekdash_notification_notes';

    protected $fillable = [
        'notification_id',
        'user_id',
        'note',
    ];

    /**
     * Get notification for this note
     */
    public static function getByNotificationId($notification_id)
    {
        $instance = new static();

        $results = $instance->wpdb->get_results($instance->wpdb->prepare(
            "SELECT * FROM {$instance->table} WHERE notification_id = %d ORDER BY created_at DESC",
            $notification_id
        ), ARRAY_A);

        return array_map([$instance, 'castAttributes'], $results);
    }
}
