dtt / laravel-uuid-model
Laravel 的 Uuid 模型
2.1.3
2023-05-16 04:12 UTC
Requires
- php: >=7.1.3
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^3.6
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-09-16 06:57:02 UTC
README
在 Eloquent 模型中使用 uuid
。
安装
composer require dtt/laravel-uuid-model
使用
创建字符串类型的 primary key。
/** * Run the migrations. * * @return void */ public function up() { Schema::create('example', function(Blueprint $table) { $table->uuid('id')->primary(); // ... }); }
并且,在你的模型中扩展 DT\Laravel\Uuid\Model
。
use DT\Laravel\Uuid\Model; class Example extends Model { //... }