jamesh/laravel-uuid

This package is abandoned and no longer maintained. The author suggests using the Laravel 9+ provide an HasUuids trait. package instead.

Eloquent UUID Trait for Laravel 6 and above.

Installs: 59 743

Dependents: 0

Suggesters: 0

Security: 0

Stars: 21

Watchers: 1

Forks: 8

Open Issues: 0

Type:plugin

2.0.1 2022-02-26 21:49 UTC

This package is auto-updated.

Last update: 2022-11-11 20:22:40 UTC


README

Eloquent UUID Trait for Laravel 5.7 and above.

⚠️ This package will no longer be maintained. The HasUuids feature has been added in Laravel 9.

Github Actions Total Downloads MIT licensed

The HasUuid Trait will add behavior to creating and saving Eloquent events for generate an Uuid.

Installation

composer require jamesh/laravel-uuid

Usage

In your migrations

Schema::create('users', function (Blueprint $table) {
    $table->uuid('id')->primary(); // Create CHAR(36)
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamp('email_verified_at')->nullable();
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();
});

In your models

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Jamesh\Uuid\HasUuid;

class User extends Model
{
    use HasUuid;
}

Unit tests

To run the tests, just run composer install and composer test.