You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
Don't know if I need to configure something or if it is a bug?
I have many columns in a datatable, two of them pointing at different relations but to same model "Group" (belongsTo relation) and also wanting the name in both columns.
In this scenario the handled_by_group.name relation gets the same values as from the column group.name. (If I don't use relation in the second column but the column-value itself in "handled_by_group_id" I can see that the ID is correct on every row, hence the function to lookup the name works.)
Column::make(Lang::get('lang.incident.fields.group_id'), "group.name")
->eagerLoadRelations()
->sortable(),
Column::make(Lang::get('lang.incident.fields.handled_by_group_id'), "handled_by_group.name")
->eagerLoadRelations()
->sortable(),
So I tried with function which works ok but seems unnecessary:
Column::make(Lang::get('lang.incident.fields.handled_by_group_id'), "handled_by_group_id")
->format(
fn($value, $row, Column $column) => ($row->handled_by_group->name ?? '')
)
->sortable(),
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Don't know if I need to configure something or if it is a bug?
I have many columns in a datatable, two of them pointing at different relations but to same model "Group" (belongsTo relation) and also wanting the name in both columns.
In this scenario the handled_by_group.name relation gets the same values as from the column group.name. (If I don't use relation in the second column but the column-value itself in "handled_by_group_id" I can see that the ID is correct on every row, hence the function to lookup the name works.)
Column::make(Lang::get('lang.incident.fields.group_id'), "group.name")
->eagerLoadRelations()
->sortable(),
Column::make(Lang::get('lang.incident.fields.handled_by_group_id'), "handled_by_group.name")
->eagerLoadRelations()
->sortable(),
So I tried with function which works ok but seems unnecessary:
Column::make(Lang::get('lang.incident.fields.handled_by_group_id'), "handled_by_group_id")
->format(
fn($value, $row, Column $column) => ($row->handled_by_group->name ?? '')
)
->sortable(),
Beta Was this translation helpful? Give feedback.
All reactions