F
Filament11mo ago
ahinkle

Table Filter, `BooleanConstraint` relationship exists

Hi friends, I'm attempting to add a QueryBuilder filter with a simple bool of if they have any registered warranties or not. Any ideas on how to get the BooleanConstraint with a relationship to exist? For example, I have this column that is working:
IconColumn::make('warranties_exists')
->label('Registered Warranty')
->exists('warranties')
...
IconColumn::make('warranties_exists')
->label('Registered Warranty')
->exists('warranties')
...
Which I'm trying to add to the filter:
BooleanConstraint::make('warranties_exists'),
BooleanConstraint::make('warranties_exists'),
which wants to apply to the current model:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.warranty_exists' in 'where clause'
SELECT count(*) AS aggregate FROM `users` WHERE (`users`.`warranties_exists` = 1)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.warranty_exists' in 'where clause'
SELECT count(*) AS aggregate FROM `users` WHERE (`users`.`warranties_exists` = 1)
which I add the relationship method, but it wants a titleAttribute attribute. Unfortunately, the titleAttribute is using the value from the boolean which would be 1.
BooleanConstraint::make('warranties_exists')
->relationship(
name: 'warranties',
titleAttribute: 'id',
),

// Any ideas how to get this to work? titleAttribute uses the value of the boolean.
BooleanConstraint::make('warranties_exists')
->relationship(
name: 'warranties',
titleAttribute: 'id',
),

// Any ideas how to get this to work? titleAttribute uses the value of the boolean.
2 Replies
Nathan
Nathan4mo ago
Hi @ahinkle did you ever figure this out?
ahinkle
ahinkleOP4mo ago
Hey @Nathan , No, unfortunately not. I decided to forgo this element.
Want results from more Discord servers?
Add your server