iotekas/uuids

There is no license information available for the latest version (dev-master) of this package.

UUID for Laravel

dev-master 2020-08-14 16:16 UTC

This package is auto-updated.

Last update: 2024-05-15 00:32:58 UTC


README

Use this package to use uuid as primary key on your model.

The package creates UUID-4 keys from the ramsey/uuid package, and automatically assigns the key to the $id field. This is a simple package with almost no configuration. There are more advanced packages out there ex.: https://github.com/spatie/laravel-binary-uuid

<?php
use iotek\UsesUuid\Uuids;

class YourModel extends Model {
  use Uuids;

You will also need to edit your migration. The 'id' column shall be set to uuid or string. On a fresh laravel you only

$table->uuid('id')->primary();

// OR
$table->string('id')->primary();