From e1364871440d98a0d6125b50df86709e04101fa2 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 20 Feb 2026 12:38:42 +0000 Subject: [PATCH] Fix date filters broken by Blade HTML-encoding of operators Filter codes containing >= or <= operators were being HTML-encoded by Blade's {{ }} syntax (e.g. >= became >=), causing a mismatch between the Livewire wire:model binding key and the PHP lookup key. This made all date filters with comparison operators silently fail. Operators are now mapped to safe aliases (gte, lte, gt, lt) in the filter code while keeping the actual SQL operator unchanged. Co-Authored-By: Claude Opus 4.6 --- src/Support/Filters/BaseFilter.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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;