PHPackages                             racklin/pkuuids - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. racklin/pkuuids

ActiveLibrary[Database &amp; ORM](/categories/database)

racklin/pkuuids
===============

Using a UUID as PrimaryKey for laravel 5.3+

47342[1 PRs](https://github.com/racklin/pkuuids/pulls)PHP

Since Apr 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/racklin/pkuuids)[ Packagist](https://packagist.org/packages/racklin/pkuuids)[ RSS](/packages/racklin-pkuuids/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Using a UUID as PrimaryKey for Laravel 5.3+
===========================================

[](#using-a-uuid-as-primarykey-for-laravel-53)

PkUuids package use `ramsey/uuid`\[\] (official installed on 5.3+) to generate a UUID\_v4(random) as primary key for `Eloquent Model`.

inspired by

Install
-------

[](#install)

1. Use composer to add the package into your project using `composer require racklin/pkuuids:dev-master`

Migrations
----------

[](#migrations)

Use a UUID as primary key, we need to change `$table->increments('id');` to `$table->uuid('id')->primary();`

Models
------

[](#models)

### Disable auto-increment primary key

[](#disable-auto-increment-primary-key)

Add `$incrementing = false;` to your Models.

### Use Traits

[](#use-traits)

Add `use PkUuuids;` to your Models.

Example:

```
