<?php
namespace Core\Helpers;

use App\Models\EmailQueue;

class EmailHelper
{
    public static function queueEmail(
        string $to,
        string $subject,
        string $body,
        ?string $senderEmail = null,
        ?string $senderName = null
    ): void {
        EmailQueue::create([
            'recipient_email' => $to,
            'subject'         => $subject,
            'body'            => $body,
            'sender_email'    => $senderEmail,
            'sender_name'     => $senderName,
            'status'          => 'pending',
            'created_at'      => date('Y-m-d H:i:s'),
        ]);
    }

    public static function getPendingEmails(): array
    {
        return EmailQueue::whereAll('status', 'pending');
    }
}
