Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/Support/Filters/BaseFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Loading