Show columns from relation on different connection?
I have tables that are related to each other on two different database connections (Integrating with a legacy system).
For simplicity, say there is
Users
on one connection and Posts
on the other. They are in a hasMany relation by Users.id
and Posts.user_id
.
The Post model has
and the User model has
In the PostResource table()
I have a column
I am not seeing the name
of the User, nor any errors.
Is it possible to show relationships over different database connections?
The User
and Post
tables each do show their own data properly.
Am I doing something wrong in general?
Do I need a RelationshipManager? That seems overkill for just showing an item from the relation, I don't want to manage/edit/attach/detach/do other relationship operations.2 Replies
Try
Tables\Columns\TextColumn::make('user.name')
with a lower case u
I am not sure if Filament is case-sensitive here
Also in my experience Filament "silently fails" if a Form or Table field does not directly match with a Model's attribute
That's the reason why you don't see an error or anything in the frontendThe actual table is more like
FooUser
.
I've tried foouser
, FooUser
, foo_user
, & fooUser
, which don't help.
I'll go see if there is any way to fail loudly π
(I think this could be an Eloquent issue, too. relationships over different connections isn't very standard)
I think I may have solved it: By using a HasOne
relation instead of a BelongsTo
.
I'm not sure it feels "correct", though