starmoozie / id-generator
laravel 生成自定义ID
1.0.0
2021-03-17 20:27 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-09-22 00:38:19 UTC
README
如何
在laravel中生成自增自定义ID
# Tambahkan pada model use Starmoozie\IdGenerator\IdGenerator; public static function boot() { parent::boot(); self::creating(function ($model) { $config = ['table' => $this->table, 'length' => 12, 'prefix' =>date('ymd')]; $model->id = IdGenerator::generate($config); }); } # Hasil 200124000001 200124000002 200124000003 200124000004 ............
SQL 支持
- MySQL
- PostgreSQL