<?php
declare(strict_types=1);

namespace App\Modules\SportsActivity\Models;

use App\Core\Model;

class Subscription extends Model
{
    protected static string $table = 'sa_subscriptions';
    protected static string $primaryKey = 'id';
    protected static bool $timestamps = true;
    protected static bool $softDelete = false;
    protected static bool $dispatchEvents = true;

    protected static array $fillable = [
        'subscription_number', 'player_id', 'group_id', 'period_start',
        'period_end', 'amount', 'discount_amount', 'final_amount',
        'payment_status', 'paid_at', 'paid_amount', 'payment_reference',
        'exemption_reason', 'exempted_by', 'notes',
    ];

    public static function getPaymentStatusOptions(): array
    {
        return [
            'unpaid' => 'غير مدفوع',
            'paid' => 'مدفوع',
            'partial' => 'مدفوع جزئياً',
            'exempt' => 'معفى',
            'overdue' => 'متأخر',
        ];
    }

    public static function generateNumber(): string
    {
        return 'SUB-' . date('Ymd') . '-' . str_pad((string)random_int(1, 9999), 4, '0', STR_PAD_LEFT);
    }
}
