mr-punyapal/laravel-extended-relationships
Adds efficient, extended Eloquent relationship helpers for Laravel models to cut queries, boost performance, and reduce duplicate code. Includes a HasExtendedRelationships trait and custom relations like belongsToManyKeys. Compatible with Laravel 11–13 and PHP 8.2+.
Performance Optimization for High-Traffic Features:
post->auditors->creator, post->auditors->updater) without manual query optimization.Developer Efficiency for Complex Relationships:
hasManyThrough chains or raw SQL) for patterns like:
belongsToManyKeys for created_by, updated_by).hasManyArrayColumn for JSON arrays).belongsToArrayColumn for string/ID arrays).Scalability for Data-Heavy Features:
tenant->users->activity).post->comments->replies->author).Cost Reduction for Legacy Systems:
posts_tags table with posts->tags array column).Use Cases with High ROI:
created_by, updated_by, deleted_by into one belongsToManyKeys relationship.hasManyArrayColumn for lightweight many-to-many (e.g., Article::tags as JSON).User::with('audited.created')->get()).belongsToArrayColumn.Adopt When:
hasManyThrough or raw SQL for audit trails).Look Elsewhere When:
hasOne/belongsTo with eager loading).For Executives:
"This package cuts database queries by 30–50% for common patterns like audit logs and tagging systems, directly improving API response times and scalability. For example, replacing manual created_by/updated_by columns with a single belongsToManyKeys relationship reduces our query count from 12 to 1 per request—saving server costs and accelerating feature delivery. The MIT license and Laravel Boost integration also lower risk and developer onboarding time."
For Engineering Leads:
"This solves a recurring pain point: writing custom relationship methods for audit trails, array columns, or legacy migrations. With belongsToManyKeys, we can replace 5+ lines of manual query logic with a single method call, while hasManyArrayColumn eliminates the need for pivot tables in simple many-to-many cases. It’s battle-tested (174 stars, Laravel 11–13 support) and integrates with Boost for real-time IDE help—ideal for teams balancing speed and scalability."
For Developers:
"No more writing boilerplate for audit logs or array relationships. Use belongsToManyKeys to map created_by, updated_by in one query, or hasManyArrayColumn to fetch related models from a JSON array. It’s like Eloquent’s hasMany but smarter—supports lazy loading, inverse relationships, and even string IDs. Plus, Boost gives you hints as you code!"
How can I help you explore Laravel packages today?