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;
});
}
}

View File

@@ -35,7 +35,8 @@
"spatie/laravel-fractal": "4.2.*",
"composer/semver": "^1.4",
"dg/rss-php": "^1.2",
"makinacorpus/php-bloom": "dev-master"
"makinacorpus/php-bloom": "dev-master",
"hashids/hashids": "2.0.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

65
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "181da7f1bb73299cdb05da4add9052dd",
"content-hash": "c432aeac72c0d98fb3fac64a5125b817",
"packages": [
{
"name": "anlutro/l4-settings",
@@ -1097,6 +1097,69 @@
],
"time": "2017-05-14T14:47:48+00:00"
},
{
"name": "hashids/hashids",
"version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/ivanakimov/hashids.php.git",
"reference": "28889ed83cdc91f4a55637daff0fb5c799eb324e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ivanakimov/hashids.php/zipball/28889ed83cdc91f4a55637daff0fb5c799eb324e",
"reference": "28889ed83cdc91f4a55637daff0fb5c799eb324e",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"php": "^5.6.4 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"autoload": {
"psr-4": {
"Hashids\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ivan Akimov",
"email": "ivan@barreleye.com",
"homepage": "https://twitter.com/IvanAkimov"
},
{
"name": "Vincent Klaiber",
"email": "hello@vinkla.com",
"homepage": "https://vinkla.com"
}
],
"description": "Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers",
"homepage": "http://hashids.org/php",
"keywords": [
"bitly",
"decode",
"encode",
"hash",
"hashid",
"hashids",
"ids",
"obfuscate",
"youtube"
],
"time": "2017-01-01T13:33:33+00:00"
},
{
"name": "igorw/get-in",
"version": "v1.0.3",