salamwaddah/laravel-relation-parser
Parse dot-notated Eloquent relationship strings into structured arrays for safe eager loading, validation, and API include parameters. Handles nested relations, making it easy to resolve and load only requested relationships in Laravel.
?include= support. Parsing model relations at boot lets you validate requested relations against what actually exists, fail fast with 422s instead of N+1s or runtime errors, and build an allowlist per endpoint — a common enterprise/API-contract requirement that otherwise gets duplicated per resource.orders?") without a separate diagram tool drifting out of date.Adopt when:
$this->hasMany(...) / belongsTo(...) returns) and are the single source of truth for the data graph.^1.4 rather than ^1.3 if Laravel 13 is on your horizon.nikic/php-parser is the heavier foundation if you ever need to go deeper, but it is a much larger commitment than this package's surface area.Look elsewhere (or build in-house) when:
Model::getRelation(), getRelations(), resolveRelationUsing(), and with() accept dynamic input on an instantiated model without any extra dependency. Prefer core if you can instantiate the model.For executives: We are evaluating a small open-source Laravel package that lets our application read its own data model — which tables relate to which — instead of us maintaining custom parsing code. It unlocks API features customers ask for (choosing which related records come back in one call) and auto-generated data diagrams for onboarding and audits. The v1.4.0 release is a maintenance update that adds Laravel 13 compatibility, which means adopting it now does not jeopardize our framework upgrade. Cost is near zero; the main risk is that it is maintained by one person, so we are scoping it to non-critical features with a plan to swap it out if it stalls.
For engineering: This is a narrow, well-bounded utility — it parses Eloquent model classes to enumerate relations and their types. Use it for ?include= allowlist validation, ERD/doc generation, and admin scaffolding. Do not put it on a request hot path; parse once at build/deploy and cache the result. It is a static analysis of model source, so anything dynamic (traits, config-driven relations, resolveRelationUsing) will be invisible — validate that assumption against our model inventory before committing. Where we only need relations on a live instance, core Laravel methods already do the job and we should not add the dependency. v1.4.0 is a Laravel 13 compatibility bump with no API changes, so the upgrade is low-risk; pin ^1.4 and add it to the third-party dependency review queue given single-maintainer status.
How can I help you explore Laravel packages today?