PHPackages                             sheldonreiff/laravel-advanced-relationships - 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. sheldonreiff/laravel-advanced-relationships

ActiveLibrary

sheldonreiff/laravel-advanced-relationships
===========================================

Multi-column and JSON relationships using awobaz/compoships and staudenmeir/eloquent-json-relations

v1.0.0(6y ago)42.9k1[2 issues](https://github.com/sheldonreiff/laravel-advanced-relationships/issues)[1 PRs](https://github.com/sheldonreiff/laravel-advanced-relationships/pulls)MITPHPPHP ^7.2

Since Jan 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sheldonreiff/laravel-advanced-relationships)[ Packagist](https://packagist.org/packages/sheldonreiff/laravel-advanced-relationships)[ RSS](/packages/sheldonreiff-laravel-advanced-relationships/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Laravel Advanced Relationships
==============================

[](#laravel-advanced-relationships)

Multi-column and JSON-column relationships for Laravel Eloquent using [awobaz/compoships](https://github.com/topclaudy/compoships) and [staudenmeir/eloquent-json-relations](https://github.com/staudenmeir/eloquent-json-relations)

In a recent project, I've encountered the need to use both multi-column and JSON-column relationships in the same model. Neither functionality is supported natively by Laravel. Two third-party packages exist that provide these functionalities separately, however, they have several conflicting methods so they can't be used together in the same class. This package combines [awobaz/compoships](https://github.com/topclaudy/compoships) and [staudenmeir/eloquent-json-relations](https://github.com/staudenmeir/eloquent-json-relations) to provide full functionality of both in the same Laravel model.

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

[](#installation)

```
composer require sheldonreiff/laravel-advanced-relationships

```

Usage
-----

[](#usage)

Add the `HasAdvancedRelationships` trait to both the parent and the related model. For all of the supported relationships, either a JSON column, multiple columns, or multiple JSON columns may be specified for the local and foreign keys as seen in the example below.

```
namespace App;

use Illuminate\Database\Eloquent\Model;

class A extends Model
{
    use \Reiff\AdvancedRelationships\HasAdvancedRelationships;

    public function b()
    {
        return $this->hasMany('B', 'f1', 'details->l1');
    }

    public function c()
    {
        return $this->hasMany('C', ['f1', 'details->f2'], ['details->l1', 'l2']);
    }
}

```

Supported relationships
-----------------------

[](#supported-relationships)

Both multi-column and JSON-column support are provided for the following relationships.

- hasOne
- hasMany
- belongsTo

Additional information
----------------------

[](#additional-information)

Refer to [awobaz/compoships](https://github.com/topclaudy/compoships) and [staudenmeir/eloquent-json-relations](https://github.com/staudenmeir/eloquent-json-relations) for additional functionality and other information. This package depends on these packages and simply implements the necessary integrations to make them work together.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

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

2313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbff6dbc14c634076c471f0b07dfdc43979f4b8a7ee62a96ee305c57e6749a8b?d=identicon)[sreiff](/maintainers/sreiff)

---

Top Contributors

[![sheldonreiff](https://avatars.githubusercontent.com/u/8636551?v=4)](https://github.com/sheldonreiff "sheldonreiff (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sheldonreiff-laravel-advanced-relationships/health.svg)

```
[![Health](https://phpackages.com/badges/sheldonreiff-laravel-advanced-relationships/health.svg)](https://phpackages.com/packages/sheldonreiff-laravel-advanced-relationships)
```

###  Alternatives

[mpyw/compoships-eager-limit

topclaudy/compoships + staudenmeir/eloquent-eager-limit

13122.4k](/packages/mpyw-compoships-eager-limit)[kitloong/eloquent-power-joins-with-compoships

The Laravel magic applied to joins, with compoships support

2616.4k](/packages/kitloong-eloquent-power-joins-with-compoships)

PHPackages © 2026

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