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

ActiveLibrary

romverner/laravel-advanced-relationships
========================================

Multi-column and JSON relationships using awobaz/compoships and staudenmeir/eloquent-json-relations, updated to work with Laravel 8. Credit goes to sheldonreiff for the original library.

v1.0.0(6y ago)018MITPHPPHP ^7.2

Since Jan 12Pushed 3y agoCompare

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

READMEChangelogDependencies (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.

Notice
------

[](#notice)

This is a forked version of the original package sheldonreiff/laravel-advanced-relationships, which was created to work with Laravel 5. I created the dev-master branch here to work with Laravel 8.

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

[](#installation)

```
If using Laravel 5-7, please use the original package originally created by sheldonreiff:
    composer require sheldonreiff/laravel-advanced-relationships

If using Laravel 8, please use the updated package:
    composer require romverner/laravel-advanced-relationships:dev-master

```

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

24

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

2261d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cb5266646eedec4ae3c347fc568b2f429c1be8e98f51764f8b1c6fb9c31b271?d=identicon)[romverner](/maintainers/romverner)

---

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/romverner-laravel-advanced-relationships/health.svg)

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

###  Alternatives

[mpyw/compoships-eager-limit

topclaudy/compoships + staudenmeir/eloquent-eager-limit

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

The Laravel magic applied to joins, with compoships support

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

PHPackages © 2026

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