mitoop/laravel-snowflake
最新稳定版本:v2.2.0
Composer 安装命令:
composer require mitoop/laravel-snowflake
包简介
README 文档
README
环境需求
- PHP:
^8.2 - Laravel:
^11|^12
安装
composer require mitoop/laravel-snowflake
发布配置文件
php artisan vendor:publish --provider="Mitoop\LaravelSnowflake\ServiceProvider"
snowflake.php配置文件
return [ // 纪元时间 'epoch' => '2023-08-01 00:00:00', // 数据中心id 范围:[0-31]. 为 null时, 随机取[0-31]的值 'datacenter_id' => null, // 工作机器id 范围:[0-31]. 为 null时, 随机取[0-31]的值 'worker_id' => null, // 序列号生成策略类 为 null 时, 使用随机数. 其他请指定类名如: RedisSequenceStrategy::class 'sequence_strategy' => null, ];
可用方法
- 模型类可使用
HasSnowflakeIdstrait, 支持多字段, 具体用法同HasUuids,HasUlidsDoc - Str 快捷方法
\Str::snowflakeId() - Blueprint方法
Schema::create('tests', function (Blueprint $table){ $table->snowflake()->primary(); $table->snowflake('another_snowflake_id'); $table->timestamps(); });
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-17