starmoozie/id-generator

laravel generate custom ID

1.0.0 2021-03-17 20:27 UTC

This package is auto-updated.

Last update: 2022-06-21 19:34:09 UTC


README

How to

Generate increment custom id pada laravel

# 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 Support

  • Mysql
  • PostgreSQL