src/Leevel/Validate/UniqueRule.php
public static function rule(string $entity, ?string $field = null, $exceptId = null, ?string $primaryKey = null, ...$additional): string
    {
        if (!type_array($additional, ['string'])) {
            $e = 'Unique additional conditions must be string.';

            throw new InvalidArgumentException($e);
        }

        $tmp = [];

        $tmp[] = $entity;
        $tmp[] = $field ?: self::PLACEHOLDER;
        $tmp[] = $exceptId ?: self::PLACEHOLDER;
        $tmp[] = $primaryKey ?: self::PLACEHOLDER;

        $tmp = array_merge($tmp, $additional);

        return 'unique:'.implode(',', $tmp);
    }
public static function rule(string $entity, ?string $field = null, $exceptId = null, ?string $primaryKey = null, ...$additional): string
    {
        if (!type_array($additional, ['string'])) {
            $e = 'Unique additional conditions must be string.';

            throw new InvalidArgumentException($e);
        }

        $tmp = [];

        $tmp[] = $entity;
        $tmp[] = $field ?: self::PLACEHOLDER;
        $tmp[] = $exceptId ?: self::PLACEHOLDER;
        $tmp[] = $primaryKey ?: self::PLACEHOLDER;

        $tmp = array_merge($tmp, $additional);

        return 'unique:'.implode(',', $tmp);
    }
创建语法规则.

@param string $entity
@param string $field
@param mixed  $exceptId
@param string $primaryKey
@param array  $additional

@return string