Skip to content

Conversation

@yajra
Copy link
Owner

@yajra yajra commented Nov 18, 2025

Fix #3261

  • 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.

PS: Test PR using cursor

yajra and others added 2 commits November 18, 2025 13:47
- 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.
@yajra yajra requested a review from Copilot November 18, 2025 05:50
Copilot finished reviewing on behalf of yajra November 18, 2025 05:52
Copy link

Copilot AI left a 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.

@yajra
Copy link
Owner Author

yajra commented Nov 18, 2025

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link

Copilot AI commented Nov 18, 2025

@yajra I've opened a new pull request, #3263, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits November 18, 2025 06:08
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
@sonarqubecloud
Copy link

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support of EloquentHasManyDeep

2 participants