Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Power Joins With Compoships Laravel Package

kitloong/eloquent-power-joins-with-compoships

View on GitHub
Deep Wiki
Context7

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

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope