New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

kitloong/eloquent-power-joins-with-compoships

The Laravel magic applied to joins, with compoships support
18,607 26
Install
composer require kitloong/eloquent-power-joins-with-compoships
Latest Version:v2.0.0
Laravel:11 · 12 · 13
License:MIT
Last Updated:Sep 22, 2025
Links: GitHub  ·  Packagist
Maintainer: kitloong

Eloquent Power Joins with Compoships Support

This package is an Eloquent Power Joins extension to support Compoships.

You can now use joins in Laravel way, with composite key support.

This package support composite keys for relation:

  1. hasOne
  2. HasMany
  3. belongsTo

You could read the detail explanation at here.

Installation

You can install the package via composer:

composer require kitloong/eloquent-power-joins-with-compoships

Usage

To implement join with composite key

select users.* from users inner join posts on users.team_id = posts.team_id and users.category_id = posts.category_id;

First, you need to define the model relationship the way Compoships did.

use Awobaz\Compoships\Compoships;
use Kirschbaum\PowerJoins\PowerJoins;

class User extends Model
{
    use PowerJoins;
    use Compoships;
    
    public function posts()
    {
        return $this->hasMany(
            Post::class, 
            ['team_id', 'category_id'], 
            ['team_id', 'category_id']
        );
    }
}

Then you can get the same result by simply write

User::joinRelationship('posts');

License

This package is open-sourced software licensed under the MIT license

Related Packages

kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

49,111,681 1,571
yadakhov/insert-on-duplicate-key

A trait for MySQL INSERT ON DUPLICATE KEY UPDATE.

3,117,053 275
pendalff/eloquent-joins

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

2,665 1
terranc/eloquent-insert-on-duplicate-key

Macros for INSERT ON DUPLICATE KEY UPDATE and INSERT IGNORE with Eloquent

1,993 0
llama-laravel/eloquent

Extends Laravel Eloquent ORM.

93 2

Version History

Version Released License
v2.0.0 MIT
v1.2.0 MIT
v1.1.0 MIT
v1.0.0 MIT