承接 romverner/laravel-advanced-relationships 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

romverner/laravel-advanced-relationships

最新稳定版本:v1.0.0

Composer 安装命令:

composer require romverner/laravel-advanced-relationships

包简介

Multi-column and JSON relationships using awobaz/compoships and staudenmeir/eloquent-json-relations, updated to work with Laravel 8. Credit goes to sheldonreiff for the original library.

README 文档

README

Multi-column and JSON-column relationships for Laravel Eloquent using awobaz/compoships and staudenmeir/eloquent-json-relations

In a recent project, I've encountered the need to use both multi-column and JSON-column relationships in the same model. Neither functionality is supported natively by Laravel. Two third-party packages exist that provide these functionalities separately, however, they have several conflicting methods so they can't be used together in the same class. This package combines awobaz/compoships and staudenmeir/eloquent-json-relations to provide full functionality of both in the same Laravel model.

Notice

This is a forked version of the original package sheldonreiff/laravel-advanced-relationships, which was created to work with Laravel 5. I created the dev-master branch here to work with Laravel 8.

Installation

If using Laravel 5-7, please use the original package originally created by sheldonreiff:
    composer require sheldonreiff/laravel-advanced-relationships

If using Laravel 8, please use the updated package:
    composer require romverner/laravel-advanced-relationships:dev-master

Usage

Add the HasAdvancedRelationships trait to both the parent and the related model. For all of the supported relationships, either a JSON column, multiple columns, or multiple JSON columns may be specified for the local and foreign keys as seen in the example below.

namespace App;

use Illuminate\Database\Eloquent\Model;

class A extends Model
{
    use \Reiff\AdvancedRelationships\HasAdvancedRelationships;
    
    public function b()
    {
        return $this->hasMany('B', 'f1', 'details->l1');
    }
    
    public function c()
    {
        return $this->hasMany('C', ['f1', 'details->f2'], ['details->l1', 'l2']);
    }
}

Supported relationships

Both multi-column and JSON-column support are provided for the following relationships.

  • hasOne
  • hasMany
  • belongsTo

Additional information

Refer to awobaz/compoships and staudenmeir/eloquent-json-relations for additional functionality and other information. This package depends on these packages and simply implements the necessary integrations to make them work together.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固