<?php

namespace Modules\MedOrganization\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

/**
 * Database notification sent to business admins when staff licenses are
 * expiring soon / have expired (spec §5 credentialing "expiry_alerts").
 * Mirrors the Essentials module's plain database notifications.
 */
class LicenseExpiryNotification extends Notification
{
    use Queueable;

    /** @var array<int, array{user: string, license_type: string, license_number: string, expiry_date: string, status: string}> */
    protected $expiring;

    /** @var int */
    protected $expiredCount;

    public function __construct(array $expiring, int $expiredCount = 0)
    {
        $this->expiring = $expiring;
        $this->expiredCount = $expiredCount;
    }

    public function via($notifiable)
    {
        return ['database'];
    }

    public function toArray($notifiable)
    {
        return [
            'title'         => __('medorganization::lang.license_expiry_alert'),
            'expiring'      => $this->expiring,
            'expired_count' => $this->expiredCount,
        ];
    }
}
