PHPackages                             danhunsaker/eloquent-meta-relate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. danhunsaker/eloquent-meta-relate

ActiveLibrary[Database &amp; ORM](/categories/database)

danhunsaker/eloquent-meta-relate
================================

Extend Eloquent relationships to support implied polymorphism and merging

v0.1.0(10y ago)027MITPHP

Since May 13Pushed 10y ago1 watchersCompare

[ Source](https://github.com/danhunsaker/eloquent-meta-relate)[ Packagist](https://packagist.org/packages/danhunsaker/eloquent-meta-relate)[ RSS](/packages/danhunsaker-eloquent-meta-relate/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Eloquent Meta-Relate
====================

[](#eloquent-meta-relate)

Extend Eloquent relationships to support implied polymorphism and merging

Installation
------------

[](#installation)

Use composer:

```
composer require danhunsaker/eloquent-meta-relate

```

Nothing to it!

Usage
-----

[](#usage)

Include the `Danhunsaker\Eloquent\Traits\MetaRelate` trait on any model you want to extend:

```
use Danhunsaker\Eloquent\Traits\MetaRelate;
use Illuminate\Database\Eloquent\Model;

class BaseModel extends Model
{
    use MetaRelate;
}
```

### Implied Polymorphic Relationships

[](#implied-polymorphic-relationships)

Now you can create implied polymorphic relationships simply by providing an array of class names, instead of a single class, wherever multiple models are part of the same relationship:

```
    public function files()
    {
        return $this->hasMany([
            'App\Models\Audio',
            'App\Models\Document',
            'App\Models\Image',
            'App\Models\Video',
        ]);
    }
```

### Relationship Merging

[](#relationship-merging)

You can also merge existing relationships:

```
    public function forkedTo()
    {
        return $this->hasMany('App\Models\Fork', 'original_id')->with('fork');
    }

    public function forkedFrom()
    {
        return $this->hasMany('App\Models\Fork', 'fork_id')->with('original');
    }

    public function allForks()
    {
        return $this->createMetaRelation()
            ->merge($this->forkedTo())
            ->merge($this->forkedFrom());
    }
```

Contributions
-------------

[](#contributions)

Contributions (issues, pull requests, etc) are always welcome on GitHub.

If you find a security issue, please [email me directly](mailto:dan.hunsaker+metarel@gmail.com).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3651d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1534396?v=4)[Hennik Hunsaker](/maintainers/danhunsaker)[@danhunsaker](https://github.com/danhunsaker)

---

Top Contributors

[![danhunsaker](https://avatars.githubusercontent.com/u/1534396?v=4)](https://github.com/danhunsaker "danhunsaker (1 commits)")

### Embed Badge

![Health badge](/badges/danhunsaker-eloquent-meta-relate/health.svg)

```
[![Health](https://phpackages.com/badges/danhunsaker-eloquent-meta-relate/health.svg)](https://phpackages.com/packages/danhunsaker-eloquent-meta-relate)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[staudenmeir/eloquent-json-relations

Laravel Eloquent relationships with JSON keys

1.1k5.8M24](/packages/staudenmeir-eloquent-json-relations)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.1M11](/packages/bavix-laravel-wallet)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[gearbox-solutions/eloquent-filemaker

A package for getting FileMaker records as Eloquent models in Laravel

6454.8k2](/packages/gearbox-solutions-eloquent-filemaker)[cybercog/laravel-ownership

Laravel Ownership simplify management of Eloquent model's owner.

9126.6k3](/packages/cybercog-laravel-ownership)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
