<?php
declare(strict_types=1);

namespace App\Modules\SportsActivity\Models;

use App\Core\Model;

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

    protected static array $fillable = [
        'facility_unit_id', 'time_bracket_id', 'group_size_min', 'group_size_max',
        'price_per_person_member', 'price_per_person_nonmember',
        'effective_from', 'effective_to', 'is_active',
    ];

    public static function getByUnit(int $unitId): array
    {
        return static::query()
            ->where('facility_unit_id', '=', $unitId)
            ->where('is_active', '=', 1)
            ->orderBy('group_size_min', 'ASC')
            ->get();
    }
}
