<?php
declare(strict_types=1);

namespace App\Modules\Rentals\Models;

use App\Core\Model;

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

    protected static array $fillable = [
        'contract_id',
        'facility_id',
        'booking_date',
        'start_time',
        'end_time',
        'status',
        'notes',
    ];

    /**
     * Get all booking statuses with Arabic labels.
     */
    public static function getStatuses(): array
    {
        return [
            'scheduled' => 'مجدول',
            'completed' => 'مكتمل',
            'cancelled' => 'ملغى',
            'no_show'   => 'لم يحضر',
        ];
    }

    /**
     * Get all bookings for a specific contract, ordered by date and time.
     */
    public static function getForContract(int $contractId): array
    {
        return static::query()
            ->where('contract_id', '=', $contractId)
            ->orderBy('booking_date', 'ASC')
            ->orderBy('start_time', 'ASC')
            ->get();
    }
}
