awkwardideas/eloquentcomposite

Eloquent 的复合键功能

2.0.2 2022-09-07 20:42 UTC

This package is auto-updated.

Last update: 2024-09-09 23:42:38 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

通过 Composer 安装

composer require awkwardideas/eloquentcomposite

添加到 config/app.php

在包服务提供者下添加

AwkwardIdeas\EloquentComposite\EloquentCompositeServiceProvider::class,

在模型中使用声明

在你的模型中,替换这一行

use Illuminate\Database\Eloquent\Model

为这一行

use AwkwardIdeas\EloquentComposite\Model;

代码使用

在你的模型中设置以下内容

protected $connection = '[your_connection_name_here]';
protected $table = '[your_table_name_here]';
protected $compositeKey = ['your', 'composite', 'key', 'columns'];

然后要更新特定列,使用

$this->UpdateWithComposite('column_name');