Skip to content

Add support for HasManyDeep relationships in EloquentDataTable - #3262

Open
yajra wants to merge 20 commits into
masterfrom
feat-add-has-many-deep-c2928
Open

Add support for HasManyDeep relationships in EloquentDataTable#3262
yajra wants to merge 20 commits into
masterfrom
feat-add-has-many-deep-c2928

Conversation

@yajra

@yajra yajra commented Nov 18, 2025

Copy link
Copy Markdown
Owner

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

Copilot AI left a comment

Copy link
Copy Markdown

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.

Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
Comment thread tests/Integration/HasManyDeepRelationTest.php
Comment thread tests/Integration/HasManyDeepRelationTest.php
Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
Comment thread src/EloquentDataTable.php Outdated
@yajra

yajra commented Nov 18, 2025

Copy link
Copy Markdown
Owner Author

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

Copilot AI commented Nov 18, 2025

Copy link
Copy Markdown

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

yajra and others added 17 commits November 28, 2025 15:42
- 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
@yajra
yajra force-pushed the feat-add-has-many-deep-c2928 branch from 8dcd08e to f2725cb Compare November 28, 2025 07:48
@sonarqubecloud

Copy link
Copy Markdown

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

3 participants