Laravel UUID, a UUID helper Library
We invest a lot in creating open source packages, and would be grateful for a sponsor if you make money from your product that uses them.
This package can be used in Laravel 10.0 or higher with PHP 8.0 and higher. There are older versions which go back to PHP7.4 and Laravel 6.
You can install the package via composer:
composer require macsidigital/laravel-uuid
This is quite a simple package, which can be used to override the primary key to uuid, or to add an additional uuid field, our preferred option to keep an incrementing index.
Add a uuid field
// primary key implementation
$table->uuid('id')->primary();
// or implementation for additional field
$table->uuid('uuid');
});
Add the trait to get automatic UUID generation
namespace App\Models;
use Uuid\Traits\GeneratesUuid;
class FakeModel extends Model
{
use GeneratesUuid;
}
That's it! unless we use a different column name for the uuid field, then we add the following method.
public function uuidColumn(): string
{
return 'id';
}
});
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email info@macsi.co.uk instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.