bearer
Sort by related hasOno of Many model field Bug
Hey guys. I have some problem with relations. Tried to sort by field which is accessible via ->hasMany()->one()->ofMany()->some_field
For example I have 2 models - Channel and ChannelPost
A Channel has many ChannelPost.
A ChannelPost have
views
field with count of views.
Now in Channel model I have this relations:
In Filament table I use Tables\Columns\TextColumn::make('lastPost.views')
When I tried to sort by this field - it was sorted randomly.
So I tried to find the problem and did some debugging.
Here we are receiving an empty model for Post - https://github.com/filamentphp/tables/blob/3.x/src/Columns/Concerns/InteractsWithTableQuery.php#L144
And then https://github.com/filamentphp/support/blob/3.x/src/Concerns/HasCellState.php#L172 - here we are getting query with channel_id = null (because empty model has id = null)
And because this it generates looong SQL order by clause: with channel_posts
.channel_id
is null
```6 replies
How to build form using some JSON structure?
For example I want to save my texts on 3 different languages and I want to store them in JSON
{
"en": {"text": "hello", "url": "https://ex.com"},
"es": {"text": "hola", "url": "https://xcx.com"},
"de": {"text": "hallo", "url": "https://de.com"}
}
How can I edit and display them in Filament. Builder seems like solution for some schema - but I need only to preserve some structure of my json, I want to have strictly 3 predefined languages.
4 replies