Looking to hire Laravel developers? Try LaraJobs

laravel-eloquent-relationships maintained by panakour

Description
programmatically get the laravel eloquent relationships.
Last update
2024/10/03 14:09 (dev-main)
License
Links
Downloads
12 122

Comments
comments powered by Disqus

Get laravel eloquent relations using reflection.

tests Code Coverage Badge Total Downloads

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);