PHPackages                             tjbp/eloquent-joins - 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. tjbp/eloquent-joins

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

tjbp/eloquent-joins
===================

Support for joins at the relationship level in Laravel's Eloquent ORM.

173988[1 PRs](https://github.com/tjbp/eloquent-joins/pulls)PHP

Since Dec 28Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tjbp/eloquent-joins)[ Packagist](https://packagist.org/packages/tjbp/eloquent-joins)[ RSS](/packages/tjbp-eloquent-joins/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Eloquent Joins
==============

[](#eloquent-joins)

[![StyleCI](https://camo.githubusercontent.com/483680cfb4f2eb427339973c00c587ff84bd0bcb19566920ecd3a5778422c5c3/68747470733a2f2f7374796c6563692e696f2f7265706f732f34353933353935352f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/45935955)[![Build Status](https://camo.githubusercontent.com/ad56077e1e7b7c678364397550f9decb5f5d78a39d9d2633a37be3c4fe6bd832/68747470733a2f2f7472617669732d63692e6f72672f746a62702f656c6f7175656e742d6a6f696e732e737667)](https://travis-ci.org/tjbp/eloquent-joins)[![Total Downloads](https://camo.githubusercontent.com/92de898fdab4679a9e4c42f1af4cc2db3ff96b4418774e220fe3e38e2d36de3c/68747470733a2f2f706f7365722e707567782e6f72672f746a62702f656c6f7175656e742d6a6f696e732f642f746f74616c2e737667)](https://packagist.org/packages/tjbp/eloquent-joins)[![Latest Stable Version](https://camo.githubusercontent.com/a02ebcd49b91b0f7b4850be2fa970cd3a6744af17a6c6cc2cac24c78d35f98f7/68747470733a2f2f706f7365722e707567782e6f72672f746a62702f656c6f7175656e742d6a6f696e732f762f737461626c652e737667)](https://packagist.org/packages/tjbp/eloquent-joins)[![Latest Unstable Version](https://camo.githubusercontent.com/f08b60da5e4954f05f93e492de54d491efdd6dc4eed6a4337ce44e3c3aad7902/68747470733a2f2f706f7365722e707567782e6f72672f746a62702f656c6f7175656e742d6a6f696e732f762f756e737461626c652e737667)](https://packagist.org/packages/tjbp/eloquent-joins)[![License](https://camo.githubusercontent.com/e097c408a183b8e515fe3814a18dbe946823f578198401ff899e25419b7f9415/68747470733a2f2f706f7365722e707567782e6f72672f746a62702f656c6f7175656e742d6a6f696e732f6c6963656e73652e737667)](https://packagist.org/packages/tjbp/eloquent-joins)

This package allows you to simply call `$model->join($relation)` to join a Laravel Eloquent relationship's table on the keys declared by your relationship. Columns will be selected automatically, and the joined records hydrated as models in the resulting collection. Laravel's Eloquent does support joins normally, but internally calls the underlying query builder, thereby expecting the name of a table and keys to join it on as arguments.

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

[](#installation)

Eloquent Joins is installable [with Composer via Packagist](https://packagist.org/packages/tjbp/eloquent-joins).

Usage
-----

[](#usage)

### Use trait

[](#use-trait)

Simply use EloquentJoins\\ModelTrait in a model:

```
namespace App;

use EloquentJoins\ModelTrait as EloquentJoinsModelTrait;

class User
{
    use EloquentJoinsModelTrait;

    protected $table = 'users';

    public function orders()
    {
        return $this->hasMany('\App\Order');
    }
}

$users = User::join('orders')->get();
```

In the above example, `$users` will contain a collection of all the User models with a corresponding Order model (since we've performed an inner join). Each corresponding Order model can be found in the `$orders` property on the User model (normally this would contain a collection of models with a matching foreign key).

You can string multiple `join()` calls, as well as use the other types of join normally available on the underlying query object (`joinWhere()`, `leftJoin()`, etc.).

### Licence

[](#licence)

Eloquent Joins is free and gratis software licensed under the [GPL3 licence](https://www.gnu.org/licenses/gpl-3.0). This allows you to use Eloquent Joins for commercial purposes, but any derivative works (adaptations to the code) must also be released under the same licence.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

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://avatars.githubusercontent.com/u/2157634?v=4)[Tom Pitcher](/maintainers/tjbp)[@tjbp](https://github.com/tjbp)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/tjbp-eloquent-joins/health.svg)

```
[![Health](https://phpackages.com/badges/tjbp-eloquent-joins/health.svg)](https://phpackages.com/packages/tjbp-eloquent-joins)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/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)
