marquine / eloquent-uuid
Uuid primary key for Laravel Eloquent Models
Installs: 10 159
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- illuminate/database: ^5.0|^6.0|^7.0
- illuminate/events: ^5.0|^6.0|^7.0
- ramsey/uuid: ^3.6
Requires (Dev)
- phpunit/phpunit: ^5.5
README
Uuid primary key for Laravel Eloquent Models.
Installation
Install through Composer
composer require marquine/eloquent-uuid
Usage
Database table
In your migration, create a column for the uuid primary key:
$table->uuid('id')->primary();
or
$table->string('id', 32)->primary();
If your primary key column name is not id
, you need to set the model's $primaryKey
property to the correct name.
Model
Use the Uuid trait in your model:
<?php namespace App; use Marquine\EloquentUuid\Uuid; use Illuminate\Database\Eloquent\Model; class User extends Model { use Uuid; }
License
Eloquent UUID is licensed under the MIT license.