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 today

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 31% 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

3700d 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

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M90](/packages/mongodb-laravel-mongodb)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.2M19](/packages/bavix-laravel-wallet)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[laravel-liberu/laravel-gedcom

A package that converts gedcom files to Eloquent models

782.5k1](/packages/laravel-liberu-laravel-gedcom)

PHPackages © 2026

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