PHPackages                             konstantinkoslow/laravel-uuid - 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. konstantinkoslow/laravel-uuid

ActiveEloquent-extension[Database &amp; ORM](/categories/database)

konstantinkoslow/laravel-uuid
=============================

UUID primary key for Laravel Eloquent Models.

v1.1(6y ago)039MITPHPPHP ^7.1.3

Since Dec 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/konstantinkoslow/laravel-uuid)[ Packagist](https://packagist.org/packages/konstantinkoslow/laravel-uuid)[ Docs](https://github.com/konstantinkoslow/laravel-uuid)[ RSS](/packages/konstantinkoslow-laravel-uuid/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

Laravel UUID
============

[](#laravel-uuid)

Trait for generating UUID primary keys for Laravel version 5.6 and higher.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require konstantinkoslow/laravel-uuid
```

Usage
-----

[](#usage)

### Laravel Migrations

[](#laravel-migrations)

To let a Model make use of UUIDs as primary key, you have to add a UUID field in your migration file and set this as primary key:

```
Schema::create('table_name', function (Blueprint $table) {
    $table->uuid('id');
    $table->primary('id');

    // or

    $table->char('key', 36)->primary();
});
```

> Eloquent will also assume that each table has a primary key column named `id`. You may define a protected `$primaryKey` property to override this convention.

For example:

```
