darkmodeee / laravel-uuid
Eloquent UUID Trait for Laravel 6 and above.
2.0.0
2021-04-30 09:32 UTC
Requires
- php: ^7.4|^8.0
- illuminate/database: ^6|^7|^8
- illuminate/support: ^6|^7|^8
Requires (Dev)
- orchestra/testbench: ^4|^5|^6
- phpunit/phpunit: ^9.1
README
Eloquent UUID Trait for Laravel 5.7 and above.
The HasUuid Trait will add behavior to creating and saving Eloquent events for generate an Uuid.
Installation
composer require jamesh/laravel-uuid
Usage
In your migrations
Schema::create('users', function (Blueprint $table) { $table->uuid('id')->primary(); // Create CHAR(36) $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); });
In your models
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Jamesh\Uuid\HasUuid; class User extends Model { use HasUuid; }
Unit tests
To run the tests, just run composer install
and composer test
.