paulhenri-l / laravel-has-uuid
laravel-has-uuid
Installs: 161
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/paulhenri-l/laravel-has-uuid
Requires
- php: ^7.3|^8.0
- illuminate/database: ^8.0
- illuminate/support: ^8.0
- ramsey/uuid: ^4.0
Requires (Dev)
- illuminate/events: ^8.0
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^5.0
README
Easily use uuids as the primary key for your eloquent models.
Installation
composer require paulhenri-l/laravel-has-uuid
Usage
This feature is provided as a trait that you should use in your models.
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Hello extends Model { use \PaulhenriL\LaravelHasUuid\HasUuid; }
You should also use the uuid filed in your migrations instead of the default id one.
Schema::create('hellos', function (Blueprint $table) { $table->uuid('id')->primary(); $table->timestamps(); });
Now whenever you'll create a new model it will be given an uuid instead of an incrementing id