Cleanup factories and seed data for airport timezone column change

This commit is contained in:
Nabeel Shahzad 2018-02-06 13:11:42 -06:00
parent 531c7ddba3
commit 7d8dc2a4d4
12 changed files with 33 additions and 36 deletions

View File

@ -4,7 +4,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 100000),
'id' => null,
'subfleet_id' => function() {
return factory(App\Models\Subfleet::class)->create()->id;
},

View File

@ -8,7 +8,7 @@ use Hashids\Hashids;
*/
$factory->define(App\Models\Airline::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'icao' => function (array $apt) use ($faker) {
$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));

View File

@ -1,6 +1,5 @@
<?php
use Hashids\Hashids;
use Faker\Generator as Faker;
/**
@ -9,7 +8,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Airport::class, function (Faker $faker) {
return [
'id' => function(array $apt) use ($faker) {
'id' => function() {
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$string = '';
$max = strlen($characters) - 1;
@ -18,16 +17,12 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
}
return $string;
#return $faker->unique()->text(5);
/*$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,
'tz' => $faker->timezone,
'timezone' => $faker->timezone,
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'fuel_100ll_cost' => $faker->randomFloat(2),

View File

@ -4,7 +4,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Fare::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'code' => $faker->text(5),
'name' => $faker->text(20),
'price' => $faker->randomFloat(2, 100, 1000),

View File

@ -8,8 +8,10 @@ $airlinesAvailable = [1];
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
return [
'id' => substr($faker->unique()->sha1, 28, 12),
'airline_id' => $faker->randomElement($airlinesAvailable),
'id' => null,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
'route_code' => $faker->randomElement(['', $faker->text(5)]),
'route_leg' => $faker->randomElement(['', $faker->text(5)]),

View File

@ -12,24 +12,22 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
return [
'id' => null,
'airline_id' => function () { # OVERRIDE THIS IF NEEDED
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'user_id' => function () { # OVERRIDE THIS IF NEEDED
'user_id' => function () {
return factory(App\Models\User::class)->create()->id;
},
'aircraft_id' => function () {
return factory(App\Models\Aircraft::class)->create()->id;
},
'flight_number' => function () {
return factory(App\Models\Flight::class)->create()->flight_number;
},
'route_code' => function(array $pirep) {
//return App\Models\Flight::where(['flight_number' => $pirep['flight_number']])->first()->route_code;
},
'route_leg' => function (array $pirep) {
//return App\Models\Flight::where('flight_number', $pirep['flight_number'])->first()->route_leg;
'flight_number' => function (array $pirep) {
return factory(App\Models\Flight::class)->create([
'airline_id' => $pirep['airline_id']
])->flight_number;
},
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},

View File

@ -11,7 +11,7 @@ use Faker\Generator as Faker;
*/
$factory->define(App\Models\Rank::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'name' => $faker->unique()->text(50),
'hours' => $faker->numberBetween(10, 50),
'auto_approve_acars' => 0,

View File

@ -4,8 +4,10 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'airline_id' => 1,
'id' => null,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'name' => $faker->unique()->text(50),
'type' => $faker->unique()->text(7),
];

View File

@ -8,7 +8,7 @@ $factory->define(App\Models\User::class, function (Faker $faker)
static $password;
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'),

View File

@ -10,7 +10,7 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago

View File

@ -10,7 +10,7 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago

View File

@ -110,73 +110,73 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago
- id: KJFK
iata: JFK
icao: KJFK
name: John F Kennedy
location: New York, New York, USA
country: United States
timezone: America/New_York
lat: 40.6399257
lon: -73.7786950
hub: 1
tz: America/New_York
- id: KBWI
iata: BWI
icao: KBWI
name: Baltimore/Washington International Thurgood Marshall Airport
location: Baltimore, MD
country: United States
timezone: America/New_York
lat: 39.1754
lon: -76.6683
tz: America/New_York
- id: KIAH
iata: IAH
icao: KIAH
name: George Bush Intercontinental Houston Airport
location: Houston, TX
country: United States
timezone: America/Chicago
lat: 29.9844
lon: -95.3414
tz: America/Chicago
- id: KORD
iata: ORD
icao: KORD
name: Chicago O'Hare International Airport
location: Chicago, IL
country: United States
timezone: America/Chicago
lat: 41.9786
lon: -87.9048
tz: America/Chicago
- id: KDFW
iata: DFW
icao: KDFW
name: Dallas Fort Worth International Airport
location: Dallas, TX
country: United States
timezone: America/Chicago
lat: 32.8968
lon: -97.038
tz: America/Chicago
- id: EFHK
iata: HEL
icao: EFHK
name: Helsinki Vantaa Airport
location: Helsinki
country: Finland
timezone: Europe/Helsinki
lat: 60.3172
lon: 24.9633
tz: Europe/Helsinki
- id: EGLL
iata: LHR
icao: EGLL
name: London Heathrow
location: London, England
timezone: Europe/London
lat: 51.4775
lon: -0.4614
tz: Europe/London
#
aircraft: