panakour / laravel-eloquent-relationships
programmatically get the laravel eloquent relationships.
Installs: 12 117
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/database: ^9.0|^10.0
- illuminate/support: ^9.0|^10.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.29
README
This will let you programmatically get the relations of models in laravel to use them how you want.
Examples
use EloquentRelationships\RelationMethods; use EloquentRelationships\Relations; $relations = new Relations(new YourModel()); //get all relations $collection = $relations->all(); //or get relations by method //belongsToMany $collection = $relations->getByMethod(RelationMethods::BelongsToMany->value); //MorphedByMany $collection = $relations->getByMethod(RelationMethods::MorphedByMany->value);