Add support for HasManyDeep relationships in EloquentDataTable - #3262
Open
yajra wants to merge 20 commits into
Open
Add support for HasManyDeep relationships in EloquentDataTable#3262yajra wants to merge 20 commits into
yajra wants to merge 20 commits into
Conversation
There was a problem hiding this comment.
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.
Owner
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
- 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.
Co-authored-by: yajra <2687997+yajra@users.noreply.github.com>
- 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
… unused parameter
…lper methods for builders and engines
yajra
force-pushed
the
feat-add-has-many-deep-c2928
branch
from
November 28, 2025 07:48
8dcd08e to
f2725cb
Compare
… across DataTable classes
…HasManyDeep relationship handling
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fix #3261
PS: Test PR using cursor