Use eloquent joins in Laravel way, with composite key support.

Overview

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

You might also like...
Laravel Eloquent CASE Statement Support

This packages adds CASE statement support to Laravel Query Builder. It supports Laravel 8.x & 9.x.

Package with small support traits and classes for the Laravel Eloquent models

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

Use auto generated UUID slugs to identify and retrieve your Eloquent models.

Laravel Eloquent UUID slug Summary About Features Requirements Installation Examples Compatibility table Alternatives Tests About By default, when get

Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.

Laravel Eloquent Scope as Select Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes an

A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.

QueryBuilderParser Status Label Status Value Build Insights Code Climate Test Coverage QueryBuilderParser is designed mainly to be used inside Laravel

A Laravel package that allows you to use multiple
A Laravel package that allows you to use multiple ".env" files in a precedent manner. Use ".env" files per domain (multi-tentant)!

Laravel Multi ENVs Use multiple .envs files and have a chain of precedence for the environment variables in these different .envs files. Use the .env

A super simple package allowing for use MySQL 'USE INDEX' and 'FORCE INDEX' statements.
A super simple package allowing for use MySQL 'USE INDEX' and 'FORCE INDEX' statements.

Laravel MySQL Use Index Scope A super simple package allowing for use MySQL USE INDEX and FORCE INDEX statements. Requirements PHP ^7.4 | ^8.0 Laravel

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Releases(v1.1.0)
Use UUID or Ulid as optional or primary key in Laravel.

Laravel OptiKey Use UUID or Ulid as optional or primary key in Laravel. composer require riipandi/laravel-optikey This package adds a very simple trai

Aris Ripandi 33 Nov 4, 2022
Validate your input data in a simple way, an easy way and right way. no framework required. For simple or large. project.

wepesi_validation this module will help to do your own input validation from http request POST or GET. INTEGRATION The integration is the simple thing

Boss 4 Dec 17, 2022
This package lets you add uuid as primary key in your laravel applications

laravel-model-uuid A Laravel package to add uuid to models Table of contents Installation Configuration Model Uuid Publishing files / configurations I

salman zafar 10 May 17, 2022
A simple laravel package to handle multiple key based model route binding

Laravel Model UUID A simple package to handle the multiple key/column based route model binding for laravel package Installation Require the package u

null 13 Mar 2, 2022
⚙️Laravel Nova Resource for a simple key/value typed setting

Laravel Nova Resource for a simple key/value typed setting Administer your Laravel Simple Setting in Nova Pre-requisites This Nova resource package re

elipZis 5 Nov 7, 2022
⚙️Simple key/value typed settings for your Laravel app with synchronized json export

Simple key/value typed settings for your Laravel app Create, store and use key/value settings, typed from numbers over dates to array, cached for quic

elipZis 8 Jan 7, 2023
A Laravel package to retrieve key management from AWS Secrets Manager

A Laravel package to retrieve key management from AWS Secrets Manager Communication via AWS Secrets Manager may incur unnecessary charges. So we devel

null 2 Oct 10, 2022
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Jan 7, 2023
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Dec 30, 2022
Tag support for Laravel Eloquent models - Taggable Trait

Laravel Taggable Trait This package is not meant to handle javascript or html in any way. This package handles database storage and read/writes only.

Rob 859 Dec 11, 2022