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.
^1.4:
composer require salamwaddah/laravel-relation-parser:^1.4
config/relation-parser.php if the package publishes config,App\Models\User::class, from php artisan tinker or a small Artisan command. Inspect the returned relation list before wiring it into anything larger. This gives you the package’s output shape and confirms it sees the relations you expect.php artisan package:discover
php artisan config:clear
If you cache config in production, rebuild it after deployment.app_path('Models'), resolves model classes, and parses each one. Cache the result:
$inventory = Cache::rememberForever('model-relations', function () {
// loop models and call the package parser for each
});
Refresh the cache during deploy or via a dedicated command.?include= parameters or to build a safe list of relations that may be exposed. Still apply your own authorization and serialization rules; the parser only tells you what relations exist.composer why-not salamwaddah/laravel-relation-parser ^1.4 if Composer refuses the update; the issue is usually another package pinning Laravel or PHP.resolveRelationUsing, package-provided dynamic relations, or relations hidden behind generated code may not appear. Verify against a model that uses those patterns.get_class_methods() and a manual review of the model. If a relation is missing, check method visibility, return type, trait usage, and whether the method actually returns an Eloquent relation.How can I help you explore Laravel packages today?