Package Data | |
---|---|
Maintainer Username: | hafael |
Maintainer Contact: | villa655321verde@gmail.com (Rafael Villa-Verde) |
Package Create Date: | 2016-07-21 |
Package Last Update: | 2024-10-17 |
Language: | PHP |
License: | Apache-2.0 |
Last Refreshed: | 2024-11-19 03:23:43 |
Package Statistics | |
---|---|
Total Downloads: | 7,203 |
Monthly Downloads: | 95 |
Daily Downloads: | 4 |
Total Stars: | 27 |
Total Watchers: | 3 |
Total Forks: | 6 |
Total Open Issues: | 1 |
LaraFlake is a Laravel 5.x Package based on Twitter Snowflake ID Generator (64 bit ID).
Only supports MySQL database. :(
Waiting for your pull request to solve this issue...
Run the composer require command from your terminal:
$ composer require hafael/laraflake
Open rootproject/config/app.php and register the required service provider above your application providers.
'providers' => [
/*
* Application Service Providers...
*/
...
Hafael\LaraFlake\LaraFlakeServiceProvider::class,
],
Run Artisan command to publish vendor config file in rootproject/config/laraflake.php
$ php artisan vendor:publish --provider="Hafael\LaraFlake\LaraFlakeServiceProvider"
Import the LaraFlakeTrait in your model and set $incrementing to false:
class User extends Authenticatable
{
use LaraFlakeTrait;
protected $table = "users";
/**
* Indicates if the IDs are auto-incrementing.
* @var bool
*/
public $incrementing = false;
...
And update the migration files to use BIGINT(20) UNSIGNED:
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigInteger('id')->unsigned()->primary();
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
...
Want to contribute? Great! Just create a pull request.
Apache 2.0
Inspired on simplicity from Particle by Silviu Schiau.