Add /api/airports with pagination to return all the airports #120
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Hashids\Hashids;
|
||||
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) {
|
||||
|
||||
return [
|
||||
'id' => strtoupper($faker->unique()->text(5)),
|
||||
'icao' => function(array $apt) { return substr($apt['id'],0, 4); },
|
||||
'id' => function(array $apt) use ($faker) {
|
||||
$hashids = new Hashids(microtime(), 5);
|
||||
$mt = str_replace('.', '', microtime(true));
|
||||
return $hashids->encode($mt);
|
||||
},
|
||||
'icao' => function(array $apt) { return $apt['id']; },
|
||||
'iata' => function (array $apt) { return $apt['id']; },
|
||||
'name' => $faker->sentence(3),
|
||||
'country' => $faker->country,
|
||||
|
||||
@@ -10,7 +10,7 @@ class CreateAirportsTable extends Migration
|
||||
Schema::create('airports', function (Blueprint $table) {
|
||||
$table->string('id', 5)->primary();
|
||||
$table->string('iata', 5)->nullable();
|
||||
$table->string('icao', 4);
|
||||
$table->string('icao', 5);
|
||||
$table->string('name', 100);
|
||||
$table->string('location', 100)->nullable();
|
||||
$table->string('country', 64)->nullable();
|
||||
|
||||
Reference in New Issue
Block a user