larastuffs / primary-uuid
在Laravel模型中使用UUID作为主键
v0.3
2021-05-17 17:47 UTC
Requires
- php: ^7.3|8.*
- illuminate/database: 6.*|7.*|8.*
- illuminate/support: 6.*|7.*|8.*
- ramsey/uuid: ^3.7|^4.0
Requires (Dev)
- fzaninotto/faker: ^1.9.1
- phpunit/phpunit: ^8.5|^9.3
This package is auto-updated.
Last update: 2024-09-18 01:16:19 UTC
README
此包提供了一个简单接口,用于在模型中使用UUID作为主键
要求
- PHP 7.2或更高版本
- Laravel 6.* | 7.* | 8.*
安装
使用以下命令使用composer安装此包
composer require larastuffs/primary-uuid
使用方法
按照说明调整您的模型和迁移
模型设置
<?php use ...; use LaraStuffs\PrimaryUUID\Eloquent\Concerns\UseUUIDAsPrimaryKey; class MyModel extends Model { use UseUUIDAsPrimaryKey; ... }
迁移设置
<?php Schema::create('table_name', function (Blueprint $table) { $table->uuid('id')->primary(); });
可能的不兼容性
贡献
欢迎贡献。Fork,改进并提交pull请求。对于错误,改进想法或其他,请创建一个问题。