Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Json Relations Laravel Package

staudenmeir/eloquent-json-relations

Adds JSON foreign key support to Laravel Eloquent relationships (belongsTo, hasMany, morph*, through). Also enables many-to-many and has-many-through relations using JSON arrays (IDs or objects) across MySQL, Postgres, SQLite, SQL Server.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enables rapid development for flexible data schemas (e.g., dynamic user permissions, multi-tenant configurations) by eliminating manual JSON parsing and custom joins.
  • Supports roadmap goals for schema evolution without sacrificing relational query capabilities—ideal for features requiring nested objects or array-based IDs (e.g., product variants, dynamic form fields).
  • "Buy" decision: Avoids reinventing the wheel for JSON relationship logic, reducing technical debt and accelerating time-to-market compared to custom solutions.
  • Use cases: Integrating third-party APIs with JSON payloads, storing tenant-specific configurations, or modeling sparse attributes in a relational database.

When to Consider This Package

  • Adopt when your schema stores foreign keys in JSON columns (e.g., arrays of IDs or nested objects) and requires efficient querying/eager loading using Eloquent syntax.
  • Use for databases with robust JSON support (MySQL 5.7+, PostgreSQL, SQL Server 2016+), where Laravel’s JSON queries are compatible.
  • Avoid if your data model is purely relational (no JSON columns), uses unsupported databases (e.g., SQLite without JSON1), or demands ultra-high throughput for JSON operations (benchmark first).

How to Pitch It (Stakeholders)

  • Executives: "This package cuts development time by 40–50% for complex data features by letting us use familiar Laravel patterns to query JSON-stored relationships—no custom code needed. It scales with our product flexibility while reducing engineering overhead and future maintenance costs."
  • Engineering: "It standardizes JSON relationship handling with zero boilerplate—just define hasManyJson or belongsToJson and query like native Eloquent. Eliminates error-prone raw SQL and manual joins, keeping our codebase clean, testable, and consistent."
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport