2017-12-13 11:50:55 +08:00
|
|
|
<?php
|
|
|
|
|
2018-01-06 00:23:26 +08:00
|
|
|
use Hashids\Hashids;
|
2017-12-13 11:50:55 +08:00
|
|
|
use Faker\Generator as Faker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add any number of airports. Don't really care if they're real or not
|
|
|
|
*/
|
|
|
|
$factory->define(App\Models\Airport::class, function (Faker $faker) {
|
2018-01-06 00:23:26 +08:00
|
|
|
|
2017-12-13 11:50:55 +08:00
|
|
|
return [
|
2018-01-06 00:23:26 +08:00
|
|
|
'id' => function(array $apt) use ($faker) {
|
2018-01-06 04:56:07 +08:00
|
|
|
$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);
|
2018-01-06 00:23:26 +08:00
|
|
|
$mt = str_replace('.', '', microtime(true));
|
2018-01-06 04:56:07 +08:00
|
|
|
return $hashids->encode($mt);*/
|
2018-01-06 00:23:26 +08:00
|
|
|
},
|
|
|
|
'icao' => function(array $apt) { return $apt['id']; },
|
2017-12-13 11:50:55 +08:00
|
|
|
'iata' => function (array $apt) { return $apt['id']; },
|
|
|
|
'name' => $faker->sentence(3),
|
|
|
|
'country' => $faker->country,
|
|
|
|
'tz' => $faker->timezone,
|
|
|
|
'lat' => $faker->latitude,
|
|
|
|
'lon' => $faker->longitude,
|
|
|
|
'fuel_100ll_cost' => $faker->randomFloat(2),
|
|
|
|
'fuel_jeta_cost' => $faker->randomFloat(2),
|
|
|
|
'fuel_mogas_cost' => $faker->randomFloat(2),
|
|
|
|
];
|
|
|
|
});
|