PHPackages                             chxj1992/eloquent-relation-plugin - 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. chxj1992/eloquent-relation-plugin

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

chxj1992/eloquent-relation-plugin
=================================

06PHP

Since Sep 27Pushed 10y ago1 watchersCompare

[ Source](https://github.com/chxj1992/eloquent-relation-plugin)[ Packagist](https://packagist.org/packages/chxj1992/eloquent-relation-plugin)[ RSS](/packages/chxj1992-eloquent-relation-plugin/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

### 这是什么?

[](#这是什么)

一般ORM将数据关系分为四类:

- hasOne
- belongsTo
- hasMany
- belongsToMany

ORM为了能方便的抽象出这四种关系,会对数据表的设计有[一定的要求](http://www.golaravel.com/laravel/docs/5.0/eloquent/#relationships). 如: 实现"一对多"关系, 要求采用在子表的各行数据中保存主表ID的设计方式来描述主表包含了多条子表数据

主表:

idname1Tom2Sandy子表:

user\_idcard\_num112321411232352845623但因为当前数据库(med)中一些表用于表示"一对多"关系的数据表设计并不符合这样的设计规范 (当前Med库中多是通过在主表中用一个集合保存子表的关联ID来描述这种关系的).

所以,本插件实现了一个新关系接口'containsMany', 它的作用是当 当前数据表采用了在主表中用集合保存子表ID的方式来表述"一对多"关系时,仍能让开发者以Eloquent式的调用来优雅的处理多个模型之间的关系.

### 使用

[](#使用)

```
// 数据模型类
class SomeModel extends Model {

    use ExtraRelations;

    // relationship model
    public function xxxs() {
        $this->containsMany('...Model', foreign_key, local_key);
    }
}

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![chxj1992](https://avatars.githubusercontent.com/u/1113743?v=4)](https://github.com/chxj1992 "chxj1992 (5 commits)")

### Embed Badge

![Health badge](/badges/chxj1992-eloquent-relation-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/chxj1992-eloquent-relation-plugin/health.svg)](https://phpackages.com/packages/chxj1992-eloquent-relation-plugin)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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