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-01-29 01:12:13 +08:00
|
|
|
'id' => null,
|
2018-02-07 03:11:42 +08:00
|
|
|
'airline_id' => function () {
|
2017-12-26 05:19:34 +08:00
|
|
|
return factory(App\Models\Airline::class)->create()->id;
|
|
|
|
},
|
2018-02-07 03:11:42 +08:00
|
|
|
'user_id' => function () {
|
2017-12-13 11:50:55 +08:00
|
|
|
return factory(App\Models\User::class)->create()->id;
|
|
|
|
},
|
|
|
|
'aircraft_id' => function () {
|
|
|
|
return factory(App\Models\Aircraft::class)->create()->id;
|
|
|
|
},
|
2018-02-07 03:11:42 +08:00
|
|
|
'flight_number' => function (array $pirep) {
|
|
|
|
return factory(App\Models\Flight::class)->create([
|
|
|
|
'airline_id' => $pirep['airline_id']
|
|
|
|
])->flight_number;
|
2017-12-13 11:50:55 +08:00
|
|
|
},
|
2018-02-07 03:11:42 +08:00
|
|
|
'route_code' => null,
|
|
|
|
'route_leg' => null,
|
2017-12-13 11:50:55 +08:00
|
|
|
'dpt_airport_id' => function () {
|
|
|
|
return factory(App\Models\Airport::class)->create()->id;
|
|
|
|
},
|
2017-12-14 00:56:26 +08:00
|
|
|
'arr_airport_id' => function () {
|
|
|
|
return factory(App\Models\Airport::class)->create()->id;
|
|
|
|
},
|
2018-01-03 04:31:00 +08:00
|
|
|
'level' => $faker->numberBetween(20, 400),
|
2018-01-30 06:29:51 +08:00
|
|
|
'distance' => $faker->randomFloat(2),
|
|
|
|
'planned_distance' => $faker->randomFloat(2),
|
2018-02-12 10:38:56 +08:00
|
|
|
'flight_time' => $faker->numberBetween(60, 360),
|
|
|
|
'planned_flight_time' => $faker->numberBetween(60, 360),
|
2018-01-31 01:07:48 +08:00
|
|
|
'zfw' => $faker->randomFloat(2),
|
|
|
|
'block_fuel' => $faker->randomFloat(2),
|
2018-01-31 01:27:39 +08:00
|
|
|
'fuel_used' => $faker->randomFloat(2),
|
2017-12-14 01:38:03 +08:00
|
|
|
'route' => $faker->text(200),
|
|
|
|
'notes' => $faker->text(200),
|
2017-12-20 10:19:36 +08:00
|
|
|
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
2018-01-30 10:30:29 +08:00
|
|
|
'source_name' => 'Test Factory',
|
2017-12-26 05:19:34 +08:00
|
|
|
'state' => PirepState::PENDING,
|
|
|
|
'status' => PirepStatus::SCHEDULED,
|
2018-01-03 04:31:00 +08:00
|
|
|
'created_at' => Carbon::now()->toDateTimeString(),
|
2017-12-13 11:50:55 +08:00
|
|
|
'updated_at' => function(array $pirep) {
|
|
|
|
return $pirep['created_at'];
|
|
|
|
},
|
|
|
|
];
|
|
|
|
});
|