notpurpell/composito
Composer 安装命令:
composer require notpurpell/composito
包简介
Composito is a small package that gives eloquent models the ability to have composite primary keys.
README 文档
README
Composito is a small package that gives eloquent models the ability to have composite primary keys through a trait.
Installation
You can install composito using Composer.
composer require notpurpell/composito
Usage
To add the composite primary key functionality to your eloquent model you must:
- Use the
HasCompositePrimaryKeytrait. - Specify the composite primary key using the
$primaryKeyproperty. - Set the
$incrementingproperty to false.
use Composito\Traits\HasCompositePrimaryKey;
class MyModel extends Eloquent
{
use HasCompositePrimaryKey;
/**
* Indicates if the IDs are auto-incrementing.
* @var bool
*/
public $incrementing = false;
/**
* The composite primary key of the model.
* @var array
*/
protected $primaryKey = [ "primary_one", "primary_two" ];
...
}
Then, you can use the create(), save(), update(), and delete() methods normally.
Support for other methods such as the find() method is coming soon.
Tests
The package contains some tests that can be run via phpunit.
./vendor/bin/phpunit
Credits
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-07