<?php
declare(strict_types=1);

namespace App\Modules\Academies\Models;

use App\Core\Model;

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

    protected static array $fillable = [
        'academy_id',
        'level_id',
        'facility_id',
        'day_of_week',
        'start_time',
        'end_time',
        'coach_name',
        'season',
        'is_active',
    ];

    /**
     * Get all schedules for a given academy, ordered by day_of_week then start_time.
     */
    public static function getForAcademy(int $academyId): array
    {
        return static::query()
            ->where('academy_id', '=', $academyId)
            ->orderBy('day_of_week', 'ASC')
            ->orderBy('start_time', 'ASC')
            ->get();
    }

    /**
     * Get all schedules for a given level.
     */
    public static function getForLevel(int $levelId): array
    {
        return static::query()
            ->where('level_id', '=', $levelId)
            ->orderBy('day_of_week', 'ASC')
            ->orderBy('start_time', 'ASC')
            ->get();
    }

    /**
     * Get day-of-week labels in Arabic (0=Sunday .. 6=Saturday).
     */
    public static function getDayLabels(): array
    {
        return [
            0 => 'الأحد',
            1 => 'الاثنين',
            2 => 'الثلاثاء',
            3 => 'الأربعاء',
            4 => 'الخميس',
            5 => 'الجمعة',
            6 => 'السبت',
        ];
    }
}
