From 927be50d9b12d2ea88695a10ffb93f0685c81235 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 5 Jan 2018 14:56:07 -0600 Subject: [PATCH] A bit more of a rudimentary id generator --- app/Database/factories/AirportFactory.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Database/factories/AirportFactory.php b/app/Database/factories/AirportFactory.php index 5967944b..2c6f214f 100644 --- a/app/Database/factories/AirportFactory.php +++ b/app/Database/factories/AirportFactory.php @@ -10,9 +10,18 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) { return [ 'id' => function(array $apt) use ($faker) { - $hashids = new Hashids(microtime(), 5); + $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + $string = ''; + $max = strlen($characters) - 1; + for ($i = 0; $i < 5; $i++) { + $string .= $characters[random_int(0, $max)]; + } + + return $string; + #return $faker->unique()->text(5); + /*$hashids = new Hashids(microtime(), 5); $mt = str_replace('.', '', microtime(true)); - return $hashids->encode($mt); + return $hashids->encode($mt);*/ }, 'icao' => function(array $apt) { return $apt['id']; }, 'iata' => function (array $apt) { return $apt['id']; },