larastuffs / primary-uuid
Use UUID as primary key on Laravel Models
v0.3
2021-05-17 17:47 UTC
Requires
- php: ^7.3|8.*
- illuminate/database: 6.*|7.*|8.*
- illuminate/support: 6.*|7.*|8.*
- ramsey/uuid: ^3.7|^4.0
Requires (Dev)
- fzaninotto/faker: ^1.9.1
- phpunit/phpunit: ^8.5|^9.3
This package is auto-updated.
Last update: 2024-11-18 01:39:33 UTC
README
this package provides a simple interface for using UUID as a primary key in models
Requirements
- PHP 7.2 or latest
- Laravel 6.* | 7.* | 8.*
Installation
Require this package with composer using the following command:
composer require larastuffs/primary-uuid
Usage
Follow the instructions to adapt your models and migrations
Model Setup
<?php use ...; use LaraStuffs\PrimaryUUID\Eloquent\Concerns\UseUUIDAsPrimaryKey; class MyModel extends Model { use UseUUIDAsPrimaryKey; ... }
Migration Setup
<?php Schema::create('table_name', function (Blueprint $table) { $table->uuid('id')->primary(); });
Possible incompatibilities
if you use closures to define your model events, I strongly recommend that you use model observers instead
Contributing
Contributions are more than welcome. Fork, improve and make a pull request. For bugs, ideas for improvement or other, please create an issue.