panakour/laravel-eloquent-relationships

programmatically get the laravel eloquent relationships.
12,123
Install
composer require panakour/laravel-eloquent-relationships
Latest Version:v0.0.1
PHP:^8.1
License:MIT
Last Updated:Oct 3, 2024
Links: GitHub  ·  Packagist
Maintainer: panakour

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

Related Packages

a2zwebltd/auditable-relations

Automatic auditing for Eloquent relationship changes (attach, detach, sync) usin...

2,664 4
zing/laravel-eloquent-relationships

More eloquent relationships for Laravel

108,264 8
skylence/laravel-model-inspector-mcp

MCP server for Laravel model introspection — relationships, attributes, scopes,...

1,162 0