<?php
declare(strict_types=1);

namespace App\Modules\SportsActivity\Models;

use App\Core\Model;
use App\Core\App;

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

    protected static array $fillable = [
        'player_id',
        'document_type',
        'file_path',
        'file_name',
        'exam_date',
        'expiry_date',
        'doctor_name',
        'clinic_name',
        'approval_status',
        'approved_by',
        'approved_at',
        'rejection_reason',
        'notes',
    ];

    /**
     * Get document type options with Arabic labels.
     */
    public static function getDocumentTypeOptions(): array
    {
        return [
            'medical_cert' => 'شهادة طبية',
            'birth_cert'   => 'شهادة ميلاد',
            'photo'        => 'صورة شخصية',
            'national_id'  => 'بطاقة رقم قومي',
            'other'        => 'أخرى',
        ];
    }

    /**
     * Get approval status options with Arabic labels.
     */
    public static function getApprovalStatusOptions(): array
    {
        return [
            'pending'  => 'قيد المراجعة',
            'approved' => 'معتمد',
            'rejected' => 'مرفوض',
            'expired'  => 'منتهي',
        ];
    }

    /**
     * Get pending medical certificate documents.
     */
    public static function getPendingMedical(): array
    {
        return static::query()
            ->where('document_type', '=', 'medical_cert')
            ->where('approval_status', '=', 'pending')
            ->orderBy('created_at', 'ASC')
            ->get();
    }
}
