dtt/laravel-uuid-model

Laravel 的 Uuid 模型

2.1.3 2023-05-16 04:12 UTC

This package is auto-updated.

Last update: 2024-09-16 06:57:02 UTC


README

Build Status Latest Stable Version License

在 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
{
	//...
}