kdaws-com/laravel-uuid is a Laravel package for eloquent uuid trait for laravel.
It currently has 0 GitHub stars and 11 downloads on Packagist (latest version 1.0.0).
Install it with composer require kdaws-com/laravel-uuid.
Discover more Laravel packages by kdaws-com
or browse all Laravel packages to compare alternatives.
Last updated
A pair of Eloquent Model Traits for dealing with orderable UUID primary or secondary keys.
Model
Use \KDAWScom\LaravelUuid\HasUuidPrimary;
class MyModel extends Model
{
Use HasUuidPrimary;
}
Migration
return new class extends Migration
{
public function up()
{
Schema::create('my_models', function (Blueprint $table) {
$table->string('id', 36)->primary();
// OR
$table->string('myKeyNameWillBeAutoDiscovered', 36)->primary();
}
}
}
Model
Use \KDAWScom\LaravelUuid\HasUuidSecondarys;
class MyModel extends Model
{
Use HasUuidSecondary;
}
Migration
return new class extends Migration
{
public function up()
{
Schema::create('my_models', function (Blueprint $table) {
/**
* Default key name is uuid
*/
$table->string('uuid', 36);
/**
* You can also set your own key name, but you must remember to set the value of:
*
* $laravelUuidSecondaryKeyName
*
* to the key name inside your models boot routine
*/
$table->string('myUuidKey', 36);
}
}
}