© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
bwurtz999

Relation Manager Wrong Record Using Union

I have a special case for a relation manager where I override the
getTableQuery
getTableQuery
and I return a union of two tables for the relation manager (two different types of orders for the OrdersRelationManager - I want them all in one place). The query works fine and shows the union properly

I use:
return $cateringOrders->union($externalOrders);
return $cateringOrders->union($externalOrders);


The issue is when I need to edit one of the orders from
$externalOrders
$externalOrders
. No matter what I do, it only returns the record for the first record of
$externalOrders
$externalOrders
.

Here is my custom edit button:

Action::make('customEdit')
                    // other customizations
                    ->form(function (RelationManager $livewire, $record) {
                        $class = new OrdersRelationManager;
                        if($record->type == 'catering') {
                            $record = Order::find($record->id);
                            return $class->getEditForm($record);
                        } else {
                            $record = ExternalOrder::find($record->id);
                            return $class->getEditExternalOrderForm($record);
                        }
                    })
Action::make('customEdit')
                    // other customizations
                    ->form(function (RelationManager $livewire, $record) {
                        $class = new OrdersRelationManager;
                        if($record->type == 'catering') {
                            $record = Order::find($record->id);
                            return $class->getEditForm($record);
                        } else {
                            $record = ExternalOrder::find($record->id);
                            return $class->getEditExternalOrderForm($record);
                        }
                    })


What makes this stranger is that the values in the table (i.e.: status - see screenshot) are correct. So it is displaying the proper data in each row but it's using the wrong record when I click on
Edit
Edit
. If I switch the union and use
return $externalOrders->union($cateringOrders);
return $externalOrders->union($cateringOrders);
I get the same issue, but with the catering orders in this case.

Why would the data in each row display correctly but the buttons in the row use the wrong record?
Screenshot_2023-09-28_at_10.44.06_AM.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

relation manager record information
FilamentFFilament / ❓┊help
2y ago
Relationship manager - Issues when using a union relation
FilamentFFilament / ❓┊help
2y ago
Current record in relation manager
FilamentFFilament / ❓┊help
3y ago
Relation manager pulls wrong data
FilamentFFilament / ❓┊help
15mo ago