How to Filter by virtual attribute.

Hi, in my model I have some attributes that are virtual, that is, they do not actually exist in the database table. I would like to know if it is possible to use them in the Table Builder filters? If so, how do I proceed with this so as not to generate an error of an inexistent column in the database. Thank you.
Solution:
The filters query against the database, so you're not going to be able to filter against anything that is not part of the model at the database level.
Jump to solution
5 Replies
awcodes
awcodes5mo ago
You would need to use virtual columns on the table. You can’t filter by attributes since the query depends on eloquent
Dennis Koch
Dennis Koch5mo ago
Just to clarify: virtual columns is a database feature.
joao nivaldo
joao nivaldoOP5mo ago
In this case, I can't do it using virtual columns from the Database. That's why I created them in the Model. In the case of creating a calculated column according to the documentation, https://filamentphp.com/docs/3.x/tables/columns/getting-started#calculated-state, would it be possible to use this column in the filters in some way?
Solution
awcodes
awcodes5mo ago
The filters query against the database, so you're not going to be able to filter against anything that is not part of the model at the database level.
joao nivaldo
joao nivaldoOP5mo ago
Right. Understood. I'll think of another way. Thank you very much.
Want results from more Discord servers?
Add your server