Package Data | |
---|---|
Maintainer Username: | racklin |
Maintainer Contact: | racklin@gmail.com (Rack Lin) |
Package Create Date: | 2017-04-18 |
Package Last Update: | 2022-07-15 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-26 15:16:22 |
Package Statistics | |
---|---|
Total Downloads: | 734 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 1 |
PkUuids package use ramsey/uuid
[https://github.com/ramsey/uuid] (official installed on 5.3+) to generate a UUID_v4(random) as primary key for Eloquent Model
.
inspired by http://stackoverflow.com/questions/31817067/laravel-5-using-a-uuid-as-primary-key
composer require racklin/pkuuids:dev-master
Use a UUID as primary key, we need to change $table->increments('id');
to $table->uuid('id')->primary();
Add $incrementing = false;
to your Models.
Add use PkUuuids;
to your Models.
Example:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Racklin\PkUuids\PkUuids;
class User extends Model
{
use PkUuids;
$incrementing = false;
}
Current package version works for Laravel 5.3+.