<?php

namespace App\Support;

use Closure;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Exists;

class TenantValidation
{
    /**
     * Build a tenant-scoped exists rule for an id column.
     */
    public static function existsForHotel(string $table, int $hotelId, string $column = 'id'): Exists
    {
        return Rule::exists($table, $column)->where(function ($query) use ($hotelId) {
            $query->where('hotel_id', $hotelId);
        });
    }

    /**
     * Build a custom exists rule when additional scoping is needed.
     */
    public static function existsWhere(string $table, Closure $scope, string $column = 'id'): Exists
    {
        return Rule::exists($table, $column)->where($scope);
    }
}

