<?php
namespace Core\Helpers;

use App\Models\SmsQueue;

class SmsHelper
{
    /**
     * Push a new SMS into the queue to be sent in the background.
     * * @param string $to Phone number(s), can be comma-separated
     * @param string $message The SMS body content
     * @param string|null $senderId Optional custom sender ID
     */
    public static function queueSms(
        string $to,
        string $message,
        ?string $senderId = null
    ): void {
        SmsQueue::create([
            'phone_number' => $to,
            'message'      => $message,
            'sender_id'    => $senderId,
            'status'       => 'pending',
            'created_at'   => date('Y-m-d H:i:s'),
        ]);
    }

    /**
     * Fetch all pending SMS from the queue
     */
    public static function getPendingSms(int $limit = 20): array
    {
        return SmsQueue::getPendingSms($limit);
    }
}