panakour/laravel-eloquent-relationships

programmatically get the laravel eloquent relationships.

v0.0.1 2023-03-09 09:29 UTC

This package is auto-updated.

Last update: 2024-04-16 16:41:47 UTC


README

tests Code Coverage Badge

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