diff --git a/database/factories/AircraftFactory.php b/database/factories/AircraftFactory.php
new file mode 100644
index 00000000..b3346721
--- /dev/null
+++ b/database/factories/AircraftFactory.php
@@ -0,0 +1,23 @@
+define(App\Models\Aircraft::class, function (Faker $faker) {
+ return [
+ 'id' => $faker->unique()->numberBetween(10, 10000),
+ 'subfleet_id' => function() {
+ return factory(App\Models\Subfleet::class)->create()->id;
+ },
+ 'airport_id' => function () {
+ return factory(App\Models\Airport::class)->create()->id;
+ },
+ 'name' => $faker->unique()->text(50),
+ 'registration' => $faker->unique()->text(10),
+ 'tail_number' => $faker->unique()->text(10),
+ 'active' => true,
+ 'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
+ 'updated_at' => function (array $pirep) {
+ return $pirep['created_at'];
+ },
+ ];
+});
diff --git a/database/factories/AirportFactory.php b/database/factories/AirportFactory.php
new file mode 100644
index 00000000..2fd72fa8
--- /dev/null
+++ b/database/factories/AirportFactory.php
@@ -0,0 +1,23 @@
+define(App\Models\Airport::class, function (Faker $faker) {
+
+ return [
+ 'id' => strtoupper($faker->unique()->text(5)),
+ 'icao' => function(array $apt) { return $apt['id']; },
+ '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),
+ ];
+});
diff --git a/database/factories/FlightFactory.php b/database/factories/FlightFactory.php
index a4e4cb43..e450f913 100644
--- a/database/factories/FlightFactory.php
+++ b/database/factories/FlightFactory.php
@@ -6,25 +6,31 @@ use Faker\Generator as Faker;
$airlinesAvailable = [1];
-$airportsAvailable = [
- 'KJFK',
- 'KAUS',
- 'EGLL',
-];
-
-$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airportsAvailable, $airlinesAvailable) {
+$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
return [
'id' => $faker->sha1,
- 'flight_number' => $faker->numberBetween(),
'airline_id' => $faker->randomElement($airlinesAvailable),
- 'dpt_airport_id' => $faker->randomElement($airportsAvailable),
- 'arr_airport_id' => $faker->randomElement($airportsAvailable),
- 'route' => $faker->text(),
+ 'flight_number' => $faker->text(10),
+ 'route_code' => $faker->randomElement(['', $faker->text(5)]),
+ 'route_leg' => $faker->randomElement(['', $faker->text(5)]),
+ 'dpt_airport_id' => function() {
+ return factory(App\Models\Airport::class)->create()->id;
+ },
+ 'arr_airport_id' => function () {
+ return factory(App\Models\Airport::class)->create()->id;
+ },
+ 'alt_airport_id' => function () {
+ return factory(App\Models\Airport::class)->create()->id;
+ },
+ 'route' => $faker->randomElement(['', $faker->text(5)]),
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->randomFloat(2),
'has_bid' => false,
'active' => true,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
+ 'updated_at' => function (array $pirep) {
+ return $pirep['created_at'];
+ },
];
});
diff --git a/database/factories/PirepFactory.php b/database/factories/PirepFactory.php
new file mode 100644
index 00000000..eea06112
--- /dev/null
+++ b/database/factories/PirepFactory.php
@@ -0,0 +1,48 @@
+define(App\Models\Pirep::class, function (Faker $faker) use ($airlinesAvailable) {
+
+ static $raw_data;
+
+ return [
+ 'id' => $faker->sha1,
+ 'airline_id' => $faker->randomElement($airlinesAvailable),
+ 'user_id' => function () { # OVERRIDE THIS IF NEEDED
+ 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;
+ },
+ 'dpt_airport_id' => function () {
+ return factory(App\Models\Airport::class)->create()->id;
+ },
+ 'flight_time' => $faker->randomFloat(2),
+ 'route' => $faker->text(),
+ 'notes' => $faker->text(),
+ 'source' => $faker->randomElement([0, 1]), # MANUAL/ACARS
+ 'status' => $faker->randomElement([-1, 0, 1]), # REJECTED/PENDING/ACCEPTED
+ 'raw_data' => $raw_data ?: $raw_data = json_encode(['key' => 'value']),
+ 'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
+ 'updated_at' => function(array $pirep) {
+ return $pirep['created_at'];
+ },
+ ];
+});
diff --git a/database/factories/SubfleetFactory.php b/database/factories/SubfleetFactory.php
new file mode 100644
index 00000000..fe85d702
--- /dev/null
+++ b/database/factories/SubfleetFactory.php
@@ -0,0 +1,12 @@
+define(App\Models\Subfleet::class, function (Faker $faker) {
+ return [
+ 'id' => $faker->unique()->numberBetween(10, 10000),
+ 'airline_id' => 1,
+ 'name' => $faker->unique()->text(50),
+ 'type' => $faker->unique()->text(7),
+ ];
+});
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index 6cdf8eb9..12ad0442 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -2,16 +2,18 @@
use Faker\Generator as Faker;
-$factory->define(App\Models\User::class, function (Faker $faker) {
+$factory->define(App\Models\User::class, function (Faker $faker)
+{
static $password;
return [
+ 'id' => $faker->unique()->numberBetween(10, 10000),
'name' => $faker->name,
'email' => $faker->safeEmail,
- 'password' => $password ?: $password = bcrypt('secret'),
+ 'password' => $password ?: $password = Hash::make('secret'),
'api_key' => $faker->sha1,
'flights' => $faker->numberBetween(0, 1000),
'flight_time' => $faker->numberBetween(0, 10000),
- 'remember_token' => str_random(10),
+ 'remember_token' => $faker->unique()->text(5),
];
});
diff --git a/phpvms.iml b/phpvms.iml
index 8b7db6af..34e6cb40 100644
--- a/phpvms.iml
+++ b/phpvms.iml
@@ -306,6 +306,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+