Filament table builder using union query

I have a table with custom union query combining records from 2 tables. The list is displayed properly but when clicking the record, it gives the wrong model and some records have the same ID thus giving back the wrong record. Is there a way so let filament table know which column should be the unique? ```
4 Replies
devpoolxx
devpoolxxOP4mo ago
Or even just get the diplayed coluimn row inside the action?
christmex
christmex4mo ago
see what is the model return, and you can choose which column you want
devpoolxx
devpoolxxOP4mo ago
Hi, thanks for the suggestion, however I want to use it in an action. The problem is im using union in my table query so 2 models. But it only injects 1 model I have tried setting a state, tooltip on the TextColumn: just so I can access the content of this column inside the action
TextColumn::make('unique_id')
->state(fn ($record) => $record->unique_id)
->tooltip(fn ($record) => $record->unique_id)
TextColumn::make('unique_id')
->state(fn ($record) => $record->unique_id)
->tooltip(fn ($record) => $record->unique_id)
and inside the EditAction:
EditAction::make()
->form(function ($form, $table) {
// state
dd($table->getColumn('unique_id')->getState()); // returns null


// tooltip
dd($table->getColumn('unique_id')->getToolTip()); // Cannot access property unique_id on null error
});
EditAction::make()
->form(function ($form, $table) {
// state
dd($table->getColumn('unique_id')->getState()); // returns null


// tooltip
dd($table->getColumn('unique_id')->getToolTip()); // Cannot access property unique_id on null error
});
Want results from more Discord servers?
Add your server