<?php
declare(strict_types=1);

namespace App\Modules\Facilities\Models;

use App\Core\Model;

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

    protected static array $fillable = [
        'facility_id',
        'day_of_week',
        'start_time',
        'end_time',
        'slot_type',
        'linked_academy_id',
        'is_active',
        'access_type',
        'member_price',
        'guest_price',
    ];

    /**
     * Get all time slots for a specific facility, ordered by day_of_week then start_time.
     */
    public static function getForFacility(int $facilityId): array
    {
        return static::query()
            ->where('facility_id', '=', $facilityId)
            ->orderBy('day_of_week', 'ASC')
            ->orderBy('start_time', 'ASC')
            ->get();
    }

    /**
     * Get slot type options with Arabic labels.
     */
    public static function getSlotTypes(): array
    {
        return [
            'available'         => 'متاح',
            'maintenance'       => 'صيانة',
            'academy_reserved'  => 'محجوز للأكاديمية',
            'blocked'           => 'محظور',
        ];
    }

    public static function getAccessTypes(): array
    {
        return [
            'all'          => 'الكل',
            'members_only' => 'أعضاء فقط',
            'vip'          => 'VIP فقط',
        ];
    }

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