use hashid vs uuid for pirep fields

This commit is contained in:
Nabeel Shahzad
2017-08-24 10:51:47 -05:00
parent 33ccc966b2
commit aba0ed2065
3 changed files with 72 additions and 5 deletions

View File

@@ -2,7 +2,8 @@
namespace App\Models\Traits;
use Webpatser\Uuid\Uuid;
use Hashids\Hashids;
trait Uuids
{
@@ -12,10 +13,12 @@ trait Uuids
static::creating(function ($model) {
$key = $model->getKeyName();
if (empty($model->{$key})) {
$model->{$key} = Uuid::generate()->string;
$hashids = new Hashids('', 8);
$id = $hashids->encode((int)microtime(true));
$model->{$key} = $id;
}
#$model->{$model->getKeyName()} = Uuid::generate()->string;
});
}
}