New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

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
Laravel:9 · 10
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

zing/laravel-eloquent-relationships

More eloquent relationships for Laravel

137,428 8
moneo/laravel-morphmap

Custom morphMap support for Laravel Framework

1,933 53
shomisha/unusual-relationships

This package offers a trait which provides your models with the ability to have...

1,041 8
pindab0ter/constrained-morph-to-for-laravel

Constrained polymorphic relationships for Laravel Eloquent - limit morphTo relat...

12,178 3
a2zwebltd/auditable-relations

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

3,519 4

Version History

Version Released PHP Laravel License
v0.0.1 ^8.1 ^9.0|^10.0 MIT