-
-
Notifications
You must be signed in to change notification settings - Fork 855
Add support for HasManyDeep relationships in EloquentDataTable #3262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Updated composer.json to include staudenmeir/eloquent-has-many-deep package. - Implemented methods in EloquentDataTable to handle HasManyDeep relationships, including foreign key and local key retrieval. - Enhanced the User model to utilize HasManyDeep for comments related to posts. - Added comments relationship to Post model. - Updated TestCase to create comments for posts during database seeding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for HasManyDeep relationships from the staudenmeir/eloquent-has-many-deep package to the EloquentDataTable class, enabling traversal of nested relationships through multiple intermediate models (e.g., User -> Posts -> Comments).
Key Changes:
- Implemented comprehensive HasManyDeep relationship handling in EloquentDataTable with methods to extract foreign keys, local keys, and intermediate table information
- Created test infrastructure including Comment model, relationships, database migrations, and integration tests
- Added the eloquent-has-many-deep package dependency to composer.json
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| composer.json | Added staudenmeir/eloquent-has-many-deep package dependency |
| src/EloquentDataTable.php | Implemented HasManyDeep relationship support with key extraction methods and join logic |
| tests/Models/Comment.php | Created new Comment model with belongsTo relationship to Post |
| tests/Models/Post.php | Added hasMany comments relationship |
| tests/Models/User.php | Added HasRelationships trait and hasManyDeep comments relationship |
| tests/TestCase.php | Added comments table migration and seeding logic |
| tests/Integration/HasManyDeepRelationTest.php | Created comprehensive integration tests for HasManyDeep functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: yajra <2687997+yajra@users.noreply.github.com>
Refactor HasManyDeep implementation addressing code review feedback
- Update test to expect 20 unique users instead of 60 comment rows - Global search on HasManyDeep returns unique parent records when selecting from parent table - This matches the behavior of other has-many relationships in the codebase
|



Fix #3261
PS: Test PR using cursor