PHP code example of starmoozie / id-generator

1. Go to this page and download the library: Download starmoozie/id-generator 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/ */

    

starmoozie / id-generator example snippets

 bash

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