Skip to content

feat(tables): inject relationship record into column item closures - #20081

Open
mohammedelkarsh wants to merge 2 commits into
filamentphp:4.xfrom
mohammedelkarsh:feat/relationship-record-in-column-closures
Open

feat(tables): inject relationship record into column item closures#20081
mohammedelkarsh wants to merge 2 commits into
filamentphp:4.xfrom
mohammedelkarsh:feat/relationship-record-in-column-closures

Conversation

@mohammedelkarsh

Copy link
Copy Markdown

Summary

  • Inject `` into per-item table column closures (color(), `tooltip()`, `url()`, `formatStateUsing()`, `icon()`, etc.) for relationship columns such as `teams.name`
  • Resolve and cache related Eloquent models alongside relationship state via getRelationshipRecords() and getRelationshipRecord()
  • Add comprehensive Pest coverage for belongs-to, many-to-many, nested, distinct list, and rendering scenarios

Fixes #19121

Test plan

  • php vendor/bin/pest tests/src/Tables/Columns/RelationshipRecordColumnTest.php (16 tests)
  • CI checks on this PR

Allow table column closures to receive the related Eloquent model for each
relationship state item via $relationshipRecord, enabling per-item styling
and formatting for relationship columns.

Fixes filamentphp#19121
@danharrin danharrin added enhancement New feature or request pending review labels Jun 30, 2026
@danharrin danharrin added this to the v4 milestone Jun 30, 2026

@danharrin danharrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the merge conflicts

Resolve conflicts in TextColumn and IconColumn by keeping upstream
a11y and formattedState improvements while preserving relationshipRecord
injection for per-item column closures.
@mohammedelkarsh

Copy link
Copy Markdown
Author

@danharrin Thanks for the review — merge conflicts are resolved.

Rebased/merged latest 4.x into this branch and kept:

  • upstream a11y / FilamentComponentAttributeBag / $formattedState / $isCollapsedList changes
  • this PR's $relationshipRecord injection for per-item column closures

Happy to address any further feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pending changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Table] - There is no way to access individual "-many" relationship models in column

2 participants