FilamentF
Filament15mo ago
abkrim

Query builder operators for TextConstraint

In doc Query Builder #text-constraints I see that I can use

By default, the following operators are available:

Contains - filters a column to contain the search term
Does not contain - filters a column to not contain the search term
Starts with - filters a column to start with the search term
Does not start with - filters a column to not start with the search term
Ends with - filters a column to end with the search term
Does not end with - filters a column to not end with the search term
Equals - filters a column to equal the search term
Does not equal - filters a column to not equal the search term
Is filled - filters a column to not be empty
Is blank - filters a column to be empty

I need use Equals

->filters([
    QueryBuilder::make()
        ->constraints([
            TextConstraint::make('modem_id')->operators(['equals']),
        ]),
])


But I am unable to locate which array content should use camelCase, lowercase,...

I also don't see any example on the subject and I can't make any progress here.
😫
Solution
Ufff.

What a pain to find it.

Also if continue way of code ->operators() and his getter getOperators() I see the class Operator

Thanks to that point I was able to locate the logic of the operators, and their location.

It is true that I forgot to follow the path of ->operators() to see that it reached the Operator class.

I think that the manual in that section could use some improvement but I don't dare to implement it since my English is pitiful.

QueryBuilder::make()
  ->constraints([
    TextConstraint::make('modem_id')>operators([
      EqualsOperator::class,
    ),
 ]),
Was this page helpful?