PHPackages                             toanld/multi-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. [Database &amp; ORM](/categories/database)
4. /
5. toanld/multi-relationships

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

toanld/multi-relationships
==========================

Compoships offers the ability to specify relationships based on two (or more) columns in Laravel's Eloquent ORM. The need to match multiple columns in the definition of an Eloquent relationship often arises when working with third party or pre existing schema/database.

v1.1.3(3y ago)02891PHP

Since Aug 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/toanld/multi-relationships)[ Packagist](https://packagist.org/packages/toanld/multi-relationships)[ RSS](/packages/toanld-multi-relationships/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (1)

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

[](#installation)

Require this package with composer. It is recommended to only require the package for development.

```
composer require toanld/multi-relationships
```

### Syntax

[](#syntax)

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Toanld\Relationship\MultiRelationships;

class Test extends Model
{
    use MultiRelationships;

    public function category(){
        //list_cat can be json ids (example: [2,3,43,23]) or string list ids (example: 2,3,43,23)
        return $this->hasOne(Category::class,'id',['cat_3','cat_2','cat_1','list_cat']);
    }
}
```

### Example

[](#example)

```
    $data = Test::with(['category:id,name'])->limit(2)->get();
    foreach ($data as $row){
        //return model category relate with field cat_1
        $category = $row->getRelationshipValue($row->cat_1,'category');
    }
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Every ~1 days

Total

4

Last Release

1352d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/toanld-multi-relationships/health.svg)

```
[![Health](https://phpackages.com/badges/toanld-multi-relationships/health.svg)](https://phpackages.com/packages/toanld-multi-relationships)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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