PHP code example of wujunze / laravel-id-generate
1. Go to this page and download the library: Download wujunze/laravel-id-generate 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/ */
wujunze / laravel-id-generate example snippets
IdGen::generate()
(string) IdGen::generate()
IdGen::generate()->string
IdGen::generate(1,'00:11:22:33:44:55');
IdGen::generate(3,'test', IdGen::NS_DNS);
IdGen::generate(4);
IdGen::generate(5,'test', IdGen::NS_DNS);
IdGen::getSamplePk();
IdGen::genIdByTypeShareKey(6,89);
IdGen::genIdByType(8);
IdGen::genCode(9, 9, 888);
IdGen::snowFlakeId();
$uuid = IdGen::import('d3d29d70-1d25-11e3-8591-034165a3a613');
$uuid = IdGen::generate(1);
dd($uuid->time);
$uuid = IdGen::generate(4);
dd($uuid->version);
/**
* Setup model event hooks
*/
public static function boot()
{
parent::boot();
self::creating(function ($model) {
$model->uuid = (string) IdGen::generate(4);
});
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'uuid';
}
public function edit(Model $model)
{
return view('someview.edit')->with([
'model' => $model,
]);
}
$uuid = IdGen::generate();
$genId= IdGen::getSamplePk();
$validator = Validator::make(['uuid' => $uuid], ['uuid' => 'uuid'], ['gen_id' => $genId]);
dd($validator->passes());