2017-12-13 11:50:55 +08:00
|
|
|
<?php
|
|
|
|
|
2018-01-03 04:31:00 +08:00
|
|
|
use Carbon\Carbon;
|
2017-12-13 11:50:55 +08:00
|
|
|
use Faker\Generator as Faker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new PIREP
|
|
|
|
*/
|
2017-12-26 05:19:34 +08:00
|
|
|
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
2017-12-13 11:50:55 +08:00
|
|
|
return [
|
2018-05-22 01:23:26 +08:00
|
|
|
'id' => $faker->unique()->numberBetween(10, 10000000),
|
2018-03-20 09:50:40 +08:00
|
|
|
'airline_id' => function () {
|
2017-12-26 05:19:34 +08:00
|
|
|
return factory(App\Models\Airline::class)->create()->id;
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'user_id' => function () {
|
2017-12-13 11:50:55 +08:00
|
|
|
return factory(App\Models\User::class)->create()->id;
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'aircraft_id' => function () {
|
2017-12-13 11:50:55 +08:00
|
|
|
return factory(App\Models\Aircraft::class)->create()->id;
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'flight_number' => function (array $pirep) {
|
2018-02-07 03:11:42 +08:00
|
|
|
return factory(App\Models\Flight::class)->create([
|
|
|
|
'airline_id' => $pirep['airline_id']
|
|
|
|
])->flight_number;
|
2017-12-13 11:50:55 +08:00
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'route_code' => null,
|
|
|
|
'route_leg' => null,
|
|
|
|
'dpt_airport_id' => function () {
|
2017-12-13 11:50:55 +08:00
|
|
|
return factory(App\Models\Airport::class)->create()->id;
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'arr_airport_id' => function () {
|
2017-12-14 00:56:26 +08:00
|
|
|
return factory(App\Models\Airport::class)->create()->id;
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'level' => $faker->numberBetween(20, 400),
|
|
|
|
'distance' => $faker->randomFloat(2, 0, 6000),
|
|
|
|
'planned_distance' => $faker->randomFloat(2, 0, 6000),
|
|
|
|
'flight_time' => $faker->numberBetween(60, 360),
|
2018-02-12 10:38:56 +08:00
|
|
|
'planned_flight_time' => $faker->numberBetween(60, 360),
|
2018-03-20 09:50:40 +08:00
|
|
|
'zfw' => $faker->randomFloat(2),
|
|
|
|
'block_fuel' => $faker->randomFloat(2, 0, 30000),
|
|
|
|
'fuel_used' => $faker->randomFloat(2, 0, 30000),
|
2018-04-05 02:03:10 +08:00
|
|
|
'block_on_time' => Carbon::now('UTC'),
|
|
|
|
'block_off_time' => function (array $pirep) {
|
|
|
|
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
|
|
|
|
},
|
2018-03-20 09:50:40 +08:00
|
|
|
'route' => $faker->text(200),
|
|
|
|
'notes' => $faker->text(200),
|
|
|
|
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
|
|
|
'source_name' => 'Test Factory',
|
|
|
|
'state' => PirepState::PENDING,
|
|
|
|
'status' => PirepStatus::SCHEDULED,
|
2018-04-05 02:03:10 +08:00
|
|
|
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
|
|
|
|
'created_at' => Carbon::now('UTC')->toDateTimeString(),
|
2018-03-20 09:50:40 +08:00
|
|
|
'updated_at' => function (array $pirep) {
|
2017-12-13 11:50:55 +08:00
|
|
|
return $pirep['created_at'];
|
|
|
|
},
|
|
|
|
];
|
|
|
|
});
|