<?php
// core/Helpers/NotificationHelper.php

namespace Core\Helpers;

use App\Models\Notification;
use Core\Auth;

class NotificationHelper
{
    /**
     * Create a notification for a specific user
     */
    public static function send(int $userId, string $title, string $message, string $type = 'info'): void 
    {
        Notification::create([
            'user_id' => $userId,
            'title'   => $title,
            'message' => $message,
            'type'    => $type,
            'is_read' => 0,
            'created_at' => date('Y-m-d H:i:s')
        ]);
    }

    /**
     * Get unread notifications for the current user
     */
    public static function getUnread(): array
    {
        $user = Auth::user();
        if (!$user) return [];

        return Notification::whereAll('user_id', $user['id'], 'AND is_read = 0 ORDER BY created_at DESC');
    }
}