michalkortas / laravel-uuid
Simply create Eloquent Models & database tables with UUID/GUID primary keys.
Installs: 497
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel-library
README
Simply create Eloquent Models & database tables with UUID/GUID primary keys.
Installation
composer require michalkortas/laravel-uuid
Usage
Add uuid as primary key in your table migration.
Schema::create('customers', function (Blueprint $table) { $table->uuid('id')->primary(); });
Add trait to your Eloquent Model.
<?php namespace AppModels; use michalkortas\LaravelUuid\traits\HasUuid; use Illuminate\Database\Eloquent\Model; class Customers extends Model { use HasUuid; }
Now, when you run migrations, newly created table has datatype ID as CHAR(36). UUID will be inserted automatically with Model::create()
method.