<?php
declare(strict_types=1);

namespace App\Modules\SportsActivity\Models;

use App\Core\Model;

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

    protected static array $fillable = [
        'code', 'name_ar', 'name_en', 'category', 'sport_type', 'icon',
        'description_ar', 'config_json', 'sort_order', 'is_active',
    ];

    public static function getCategoryOptions(): array
    {
        return [
            'individual' => 'فردية',
            'team'       => 'جماعية',
            'racket'     => 'مضرب',
            'aquatic'    => 'مائية',
            'combat'     => 'قتالية',
            'leisure'    => 'ترفيهية',
        ];
    }

    public function getCategoryLabel(): string
    {
        return static::getCategoryOptions()[$this->category] ?? $this->category;
    }

    public static function getActive(): array
    {
        return static::query()
            ->where('is_active', '=', 1)
            ->orderBy('sort_order', 'ASC')
            ->get();
    }
}
