1. Go to this page and download the library: Download dive-be/laravel-snowflake library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dive-be / laravel-snowflake example snippets
return [
/**
* Set this value to today when starting a new app.
* You will have 69 years before you run out of snowflakes.
*/
'start_date' => '2022-04-10',
];
Schema::table('products', static function (Blueprint $table) {
$table->snowflake();
$table->foreignSnowflake('variant_id')->constrained();
});
class Product extends Model
{
use HasSnowflake;
}
Snowflake::id(); // Facade
snowflake(); // Helper
app('snowflake'); // Service Locator
// Dependency Injection
public function __construct(\Godruoyi\Snowflake\Snowflake $snowflake) {}