diff --git a/src/Support/Filters/BaseFilter.php b/src/Support/Filters/BaseFilter.php index b440552..2a4e2e4 100644 --- a/src/Support/Filters/BaseFilter.php +++ b/src/Support/Filters/BaseFilter.php @@ -21,7 +21,7 @@ public function __construct($key, $label) { $this->key = $key; $this->label = $label; - $this->code = $label.':'.$this->operator; + $this->code = $this->buildCode(); } public static function make($label, $key = null): static @@ -61,11 +61,30 @@ public function component(): string public function useOperator(string $operator): static { $this->operator = $operator; - $this->code = $this->label.':'.$this->operator; + $this->code = $this->buildCode(); return $this; } + /** + * Build the filter code from the label and a Blade-safe operator alias. + * + * Operators like >= and <= are mapped to gte/lte so that Blade's {{ }} + * HTML-encoding does not break wire:model bindings. + */ + private function buildCode(): string + { + $operator = match ($this->operator) { + '>=' => 'gte', + '<=' => 'lte', + '>' => 'gt', + '<' => 'lt', + default => $this->operator, + }; + + return $this->label.':'.$operator; + } + public function useComponent(string $component): static { $this->component = $component;