定制 kitloong/eloquent-power-joins-with-compoships 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kitloong/eloquent-power-joins-with-compoships

最新稳定版本:v2.0.0

Composer 安装命令:

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

包简介

The Laravel magic applied to joins, with compoships support

README 文档

README

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

统计信息

  • 总下载量: 15.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04