Filters not returning data in query when using ->multiple()
I have the following filters for my table:
As you can see the second filter has multiple, but for some reason, when trying to dd the default record in the query, I get an empty array?
14 Replies
But, if I dont have multiple (like in the first filter), then it returns the id (as it should)
try
->default([auth()->id()])
yeah I noticed thats why I deleted the comment xD
ahaha
It definitely has to do with the way Im processing the json data
collaborators_id is being stored as a json?
yess
You can check the repo here
->query(fn (Builder $query, $data): Builder => $query->whereJsonContains('collaborators_id',$data)) ?
just went to the docs how to query json using Query Builder, don't know if it works :/
The issue atm is that I cant set a value as default
->default($userModel::where('id',auth()->id())->first()->pluck('name', 'id')) ? or in a closure
nope :/, still the same
I will ask copilot 😅
damn it. Best of luck and share the solution if you find it 🙂
I have made some progress, however I have a very weird issue, for some reason, no matter what default values wont be applied. For example
https://filamentphp.com/docs/3.x/tables/filters/select#applying-select-filters-by-default
I put this in my filters array as a test:
And draft wasnt applied as a default value
@Bruno Pereira This is my solution
Oh I see, in this you're not preloading the data, but initially you were, maybe that was the problem because the builder wasnt getting any data.