laravolt / eloquent-uuid
Universally Unique Identifier (UUID) for Laravel Eloquent
Installs: 1 301
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=5.5.0
- ramsey/uuid: ^3.0
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
This package is auto-updated.
Last update: 2024-12-05 19:52:46 UTC
README
Generate UUID automatically when creating/inserting new data.
Install
Via Composer
$ composer require laravolt/eloquent-uuid
Then register the service provider, head over your config/app.php
file and add the following line into the providers
array:
Laravolt\Database\Eloquent\UuidServiceProvider::class,
Usage
Create/Alter Database Table Column Type
Schema::create('users', function (Blueprint $table) { // Create UUID column $table->char('id', 32)->primary(); $table->string('name'); });
Implement in Eloquent Model
<?php namespace App; use Laravolt\Contracts\Eloquent\Uuid as UuidContract; use Laravolt\Database\Eloquent\Uuid; class Book extends Model implements UuidContract { use Uuid; // Uuid Columns protected $uuid = ['id'];