toanld/multi-relationships 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

toanld/multi-relationships

最新稳定版本:v1.1.3

Composer 安装命令:

composer require toanld/multi-relationships

包简介

Compoships offers the ability to specify relationships based on two (or more) columns in Laravel's Eloquent ORM. The need to match multiple columns in the definition of an Eloquent relationship often arises when working with third party or pre existing schema/database.

README 文档

README

Require this package with composer. It is recommended to only require the package for development.

composer require toanld/multi-relationships

Syntax

namespace App;

use Illuminate\Database\Eloquent\Model;
use Toanld\Relationship\MultiRelationships;

class Test extends Model
{
    use MultiRelationships;
    
    public function category(){
        //list_cat can be json ids (example: [2,3,43,23]) or string list ids (example: 2,3,43,23)
        return $this->hasOne(Category::class,'id',['cat_3','cat_2','cat_1','list_cat']);
    }
}

Example

    $data = Test::with(['category:id,name'])->limit(2)->get();
    foreach ($data as $row){
        //return model category relate with field cat_1
        $category = $row->getRelationshipValue($row->cat_1,'category');
    }

统计信息

  • 总下载量: 289
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固