Binding TextColumn with a BelongsToMany relation
How can I bind a TextColumn with a belongsToMany relation. Not sure if I am making a mistake. For a customer_orders, I have an addresses with a BelongsToMany relationship because a customer can have a billing and a shipping address. The customers name is stored on the address table and I want to show that on the Order resource on filament. How do I go about doing this? should I use a ViewColumn?
I tried this, will it work
4 Replies
ok, got this to work with
getStateUsing
instead of formatStateUsing
. Here is the docs that helped with it https://filamentphp.com/docs/2.x/tables/columns/getting-started#calculated-stateFilament
Getting started - Columns - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
The only problem with this approach is, I am not able to use searchable with this
Any idea how I can make it searchable?
maybe
searchable(['shippingAddress.first_name', 'shippingAddress.last_name'])
thank you. let me try this
@danharrin I get this error
Column not found: 1054 Unknown column 'shippingAddress.first_name' in 'where clause'
Its looking for it on the parent table and not the pivot