Reorganized folders to try to clean up the root folder a bit

This commit is contained in:
Nabeel Shahzad
2017-12-14 10:38:10 -06:00
parent 40aab22901
commit aa57ab515f
708 changed files with 101315 additions and 89 deletions

View File

@@ -35,7 +35,7 @@ class Kernel extends ConsoleKernel
*/
protected function commands()
{
require base_path('routes/console.php');
require app_path('Routes/console.php');
$this->load(__DIR__ . '/Commands');
}
}

1
app/Database/.gitignore vendored Executable file
View File

@@ -0,0 +1 @@
*.sqlite

View File

@@ -0,0 +1,23 @@
<?php
use Faker\Generator as Faker;
$factory->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'];
},
];
});

View File

@@ -0,0 +1,23 @@
<?php
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 $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),
];
});

View File

@@ -0,0 +1,13 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Fare::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 10000),
'code' => $faker->text(5),
'name' => $faker->text(20),
'price' => $faker->randomFloat(2, 100, 1000),
'capacity' => $faker->randomFloat(0, 20, 500),
];
});

View File

@@ -0,0 +1,36 @@
<?php
use Faker\Generator as Faker;
# Match the list available in tests/data/*.yml
$airlinesAvailable = [1];
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
return [
'id' => substr($faker->unique()->sha1, 0, 12),
'airline_id' => $faker->randomElement($airlinesAvailable),
'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'];
},
];
});

View File

@@ -0,0 +1,51 @@
<?php
use Faker\Generator as Faker;
# Match the list available in tests/data/*.yml
$airlinesAvailable = [1];
/**
* Create a new PIREP
*/
$factory->define(App\Models\Pirep::class, function (Faker $faker) use ($airlinesAvailable) {
static $raw_data;
return [
'id' => substr($faker->unique()->sha1, 0, 12),
'airline_id' => 1, #$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;
},
'arr_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'flight_time' => $faker->randomFloat(2),
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([0, 1]), # MANUAL/ACARS
'status' => config('enums.pirep_status.PENDING'), //$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'];
},
];
});

View File

@@ -0,0 +1,12 @@
<?php
use Faker\Generator as Faker;
$factory->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),
];
});

View File

@@ -0,0 +1,21 @@
<?php
use Faker\Generator as 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 = Hash::make('secret'),
'api_key' => $faker->sha1,
'airline_id' => 1,
'rank_id' => 1,
'flights' => $faker->numberBetween(0, 1000),
'flight_time' => $faker->numberBetween(0, 10000),
'remember_token' => $faker->unique()->text(5),
];
});

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,116 @@
<?php
use App\Models\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable();
$table->string('email')->unique();
$table->string('password');
$table->string('api_key', 40)->nullable();
$table->unsignedInteger('airline_id');
$table->unsignedInteger('rank_id');
$table->string('home_airport_id', 5)->nullable();
$table->string('curr_airport_id', 5)->nullable();
$table->string('last_pirep_id', 12)->nullable();
$table->unsignedBigInteger('flights')->default(0);
$table->unsignedBigInteger('flight_time')->default(0);
$table->decimal('balance', 19)->nullable();
$table->string('timezone', 64)->nullable();
$table->boolean('active')->nullable();
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
$table->index('email');
$table->index('api_key');
});
// Create table for storing roles
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
// Create table for associating roles to users (Many-to-Many)
Schema::create('role_user', function (Blueprint $table) {
$table->unsignedInteger('user_id');
$table->unsignedInteger('role_id');
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'role_id']);
$table->index(['role_id', 'user_id']);
});
// Create table for storing permissions
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
// Create table for associating permissions to roles (Many-to-Many)
Schema::create('permission_role', function (Blueprint $table) {
$table->unsignedInteger('permission_id');
$table->unsignedInteger('role_id');
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
});
# create a default user/role
$roles = [
[
'id' => 1,
'name' => 'admin',
'display_name' => 'Administrators',
],
[
'id' => 2,
'name' => 'user',
'display_name' => 'Pilot'
],
];
$this->addData('roles', $roles);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
Schema::dropIfExists('permission_role');
Schema::dropIfExists('permissions');
Schema::dropIfExists('role_user');
Schema::dropIfExists('roles');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAirlinesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('airlines', function (Blueprint $table) {
$table->increments('id');
$table->string('icao', 5);
$table->string('iata', 5)->nullable();
$table->string('name', 50);
$table->string('country', 2)->nullable();
$table->string('logo', 255)->nullable();
$table->boolean('active');
$table->timestamps();
$table->index('icao');
$table->unique('icao');
$table->index('iata');
$table->unique('iata');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('airlines');
}
}

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAircraftsTable extends Migration
{
public function up()
{
Schema::create('aircraft', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('subfleet_id');
$table->string('airport_id', 5)->nullable();
$table->string('hex_code', 10)->nullable();
$table->string('name', 50);
$table->string('registration', 10)->nullable();
$table->string('tail_number', 10)->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
$table->unique('registration');
});
}
public function down()
{
Schema::dropIfExists('aircraft');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateFaresTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('fares', function (Blueprint $table) {
$table->increments('id');
$table->string('code', 50);
$table->string('name', 50);
$table->unsignedDecimal('price', 19)->default(0.00);
$table->unsignedDecimal('cost', 19)->default(0.00);
$table->unsignedInteger('capacity')->default(0);
$table->string('notes')->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('fares');
}
}

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAirportsTable extends Migration
{
public function up()
{
Schema::create('airports', function (Blueprint $table) {
$table->string('id', 5)->primary();
$table->string('iata', 5)->nullable();
$table->string('icao', 5);
$table->string('name', 100);
$table->string('location', 100)->nullable();
$table->string('country', 64)->nullable();
$table->string('tz', 64)->nullable();
$table->unsignedDecimal('fuel_100ll_cost', 19)->default(0);
$table->unsignedDecimal('fuel_jeta_cost', 19)->default(0);
$table->unsignedDecimal('fuel_mogas_cost', 19)->default(0);
$table->float('lat', 7, 4)->default(0.0)->nullable();
$table->float('lon', 7, 4)->default(0.0)->nullable();
});
}
public function down()
{
Schema::dropIfExists('airports');
}
}

View File

@@ -0,0 +1,64 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateFlightTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->string('id', 12);
$table->unsignedInteger('airline_id');
$table->string('flight_number', 10);
$table->string('route_code', 5)->nullable();
$table->string('route_leg', 5)->nullable();
$table->string('dpt_airport_id', 5);
$table->string('arr_airport_id', 5);
$table->string('alt_airport_id', 5)->nullable();
$table->text('route')->nullable();
$table->string('dpt_time', 10)->nullable();
$table->string('arr_time', 10)->nullable();
$table->unsignedDecimal('flight_time', 19)->nullable();
$table->text('notes')->nullable();
$table->boolean('has_bid')->default(false);
$table->boolean('active')->default(true);
$table->timestamps();
$table->primary('id');
$table->unique('flight_number');
$table->index('flight_number');
$table->index('dpt_airport_id');
$table->index('arr_airport_id');
});
Schema::create('flight_fields', function (Blueprint $table) {
$table->increments('id');
$table->string('flight_id', 12);
$table->string('name', 50);
$table->text('value');
$table->timestamps();
$table->index('flight_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('flights');
Schema::drop('flight_fields');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateRanksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ranks', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50);
$table->unsignedInteger('hours')->default(0);
$table->boolean('auto_approve_acars')->default(false);
$table->boolean('auto_approve_manual')->default(false);
$table->boolean('auto_promote')->default(true);
$table->timestamps();
$table->unique('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ranks');
}
}

View File

@@ -0,0 +1,80 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateSubfleetTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subfleets', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('airline_id')->nullable();
$table->string('name', 50);
$table->string('type', 7);
$table->unsignedTinyInteger('fuel_type')->nullable();
$table->unsignedDecimal('cargo_capacity', 19)->nullable();
$table->unsignedDecimal('fuel_capacity', 19)->nullable();
$table->unsignedDecimal('gross_weight', 19)->nullable();
$table->timestamps();
});
Schema::create('subfleet_expenses', function(Blueprint $table) {
$table->unsignedBigInteger('subfleet_id');
$table->string('name', 50);
$table->unsignedDecimal('cost', 19);
$table->primary(['subfleet_id', 'name']);
});
Schema::create('subfleet_fare', function (Blueprint $table) {
$table->unsignedInteger('subfleet_id');
$table->unsignedInteger('fare_id');
$table->unsignedDecimal('price', 19)->nullable();
$table->unsignedDecimal('cost', 19)->nullable();
$table->unsignedInteger('capacity')->nullable();
$table->timestamps();
$table->primary(['subfleet_id', 'fare_id']);
$table->index(['fare_id', 'subfleet_id']);
});
Schema::create('subfleet_flight', function(Blueprint $table) {
$table->unsignedInteger('subfleet_id');
$table->string('flight_id', 12);
$table->primary(['subfleet_id', 'flight_id']);
$table->index(['flight_id', 'subfleet_id']);
});
Schema::create('subfleet_rank', function(Blueprint $table) {
$table->unsignedInteger('rank_id');
$table->unsignedInteger('subfleet_id');
$table->unsignedDecimal('acars_pay', 19)->nullable();
$table->unsignedDecimal('manual_pay', 19)->nullable();
$table->primary(['rank_id', 'subfleet_id']);
$table->index(['subfleet_id', 'rank_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subfleets');
Schema::dropIfExists('subfleet_expenses');
Schema::dropIfExists('subfleet_fare');
Schema::dropIfExists('subfleet_flight');
Schema::dropIfExists('subfleet_rank');
}
}

View File

@@ -0,0 +1,117 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePirepTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('pireps', function (Blueprint $table) {
$table->string('id', 12);
$table->unsignedInteger('user_id');
$table->unsignedInteger('airline_id');
$table->unsignedInteger('aircraft_id')->nullable();
$table->string('flight_id', 12)->nullable();
$table->string('flight_number', 10)->nullable();
$table->string('route_code', 5)->nullable();
$table->string('route_leg', 5)->nullable();
$table->string('dpt_airport_id', 5);
$table->string('arr_airport_id', 5);
$table->unsignedDecimal('flight_time', 19);
$table->unsignedDecimal('gross_weight', 19)->nullable();
$table->unsignedDecimal('fuel_used', 19)->nullable();
$table->string('route', 250)->nullable();
$table->string('notes', 250)->nullable();
$table->unsignedTinyInteger('source')->default(0);
$table->tinyInteger('status')->default(0); # -1 rejected, 0 pending, 1 accepted
$table->longText('raw_data')->nullable();
$table->timestamps();
$table->softDeletes();
$table->primary('id');
$table->index('user_id');
$table->index('flight_id');
$table->index('dpt_airport_id');
$table->index('arr_airport_id');
});
Schema::create('pirep_comments', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->unsignedInteger('user_id');
$table->text('comment');
$table->timestamps();
});
Schema::create('pirep_events', function(Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('event', 64);
$table->dateTime('dt');
});
/*
* Financial tables/fields
*/
Schema::create('pirep_expenses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('name');
$table->double('value', 19, 2)->nullable();
$table->index('pirep_id');
});
Schema::create('pirep_fares', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->unsignedBigInteger('fare_id');
$table->unsignedInteger('count')->nullable();
$table->index('pirep_id');
});
/*
* Additional PIREP data
*/
Schema::create('pirep_fields', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 50);
$table->boolean('required')->default(false);
$table->timestamps();
});
Schema::create('pirep_field_values', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('name', 50);
$table->string('value')->nullable();
$table->string('source')->nullable();
$table->timestamps();
$table->index('pirep_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pireps');
Schema::dropIfExists('pirep_comments');
Schema::dropIfExists('pirep_expenses');
Schema::dropIfExists('pirep_fares');
Schema::dropIfExists('pirep_fields');
Schema::dropIfExists('pirep_field_values');
}
}

View File

@@ -0,0 +1,111 @@
<?php
use App\Models\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('order')->default(99);
$table->string('name');
$table->string('key');
$table->string('value');
$table->string('group')->nullable();
$table->string('type')->nullable();
$table->string('options')->nullable();
$table->string('description')->nullable();
$table->timestamps();
$table->unique('key');
});
/**
* Initial default settings
*/
$settings = [
[
'order' => 1,
'name' => 'Start Date',
'group' => '',
'key' => 'general.start_date',
'value' => '',
'type' => 'date',
'description' => 'The date your VA started',
],
[
'order' => 2,
'name' => 'Currency to Use',
'group' => 'general',
'key' => 'general.currency',
'value' => 'dollar',
'type' => 'text',
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
'description' => 'Currency to show in the interface',
],
[
'order' => 10,
'name' => 'Flights from Current',
'group' => 'flights',
'key' => 'flights.only_flights_from_current',
'value' => true,
'type' => 'boolean',
'description' => 'Only allow flights from current location',
],
[
'order' => 20,
'name' => 'Disable flight on bid',
'group' => 'bids',
'key' => 'bids.disable_flight_on_bid',
'value' => true,
'type' => 'boolean',
'description' => 'When a flight is bid on, no one else can bid on it',
],
[
'order' => 21,
'name' => 'Allow multiple bids',
'group' => 'bids',
'key' => 'bids.allow_multiple_bids',
'value' => true,
'type' => 'boolean',
'description' => 'Whether or not someone can bid on multiple flights',
],
[
'order' => 30,
'name' => 'Hide Inactive Pilots',
'group' => 'pilots',
'key' => 'pilots.hide_inactive',
'value' => true,
'type' => 'boolean',
'description' => 'Don\'t show inactive pilots in the public view',
],
[
'order' => 31,
'name' => 'Pilot ID Length',
'group' => 'pilots',
'key' => 'pilots.id_length',
'value' => 4,
'type' => 'int',
'description' => 'The length of a pilot\'s ID',
],
];
$this->addData('settings', $settings);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('settings');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBidsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_bids', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('flight_id', 12);
$table->timestamps();
$table->index('user_id');
$table->index(['user_id', 'flight_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_bids');
}
}

1
app/Database/seeds/.gitkeep Executable file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Map these other environments to a specific seed file
* @var array
*/
public static $seed_mapper = [
'local' => 'dev',
'qa' => 'dev',
'staging' => 'dev',
];
/**
* Run the database seeds.
*/
public function run()
{
$env = App::environment();
if(array_key_exists($env, self::$seed_mapper)) {
$env = self::$seed_mapper[$env];
}
$path = database_path('seeds/'.$env.'.yml');
print("Seeding seeds/$env.yml\n");
if(!file_exists($path)) {
$path = database_path('seeds/prod.yml');
}
$svc = app('App\Services\DatabaseService');
$svc->seed_from_yaml_file($path);
}
}

368
app/Database/seeds/dev.yml Normal file
View File

@@ -0,0 +1,368 @@
#
airlines:
- id: 1
icao: VMS
iata: VM
name: phpvms airlines
active: 1
created_at: now
updated_at: now
users:
- id: 1
name: Admin User
email: admin@phpvms.net
password: admin
api_key: testadminapikey
airline_id: 1
rank_id: 1
home_airport_id: KAUS
curr_airport_id: KJFK
flights: 1
flight_time: 43200
created_at: now
updated_at: now
active: 1
- id: 2
name: Carla Walters
email: carla.walters68@example.com
password: admin
api_key: testuserapikey1
airline_id: 1
rank_id: 1
home_airport_id: KJFK
curr_airport_id: KJFK
flights: 1
flight_time: 43200
created_at: now
updated_at: now
active: 1
- id: 3
name: Raymond Pearson
email: raymond.pearson56@example.com
password: admin
api_key: testuserapikey2
airline_id: 1
rank_id: 1
home_airport_id: KJFK
curr_airport_id: KAUS
flights: 1
flight_time: 43200
created_at: now
updated_at: now
active: 0
role_user:
- user_id: 1
role_id: 1
- user_id: 1
role_id: 2
- user_id: 2
role_id: 2
- user_id: 3
role_id: 2
# ranks
ranks:
- id: 1
name: New Pilot
hours: 0
- id: 2
name: Junior First Officer
hours: 10
- id: 3
name: First Officer
hours: 15
auto_approve_acars: 1
auto_approve_manual: 1
- id: 4
name: Senior Captain
hours: 20
auto_approve_acars: 1
auto_approve_manual: 1
auto_promote: 0
airports:
- id: KAUS
iata: AUS
icao: KAUS
name: Austin-Bergstrom
location: Austin, Texas, USA
lat: 30.1945278
lon: -97.6698889
tz: America/Chicago
- id: KJFK
iata: JFK
icao: KJFK
name: John F Kennedy
location: New York, New York, USA
lat: 40.6399257
lon: -73.7786950
tz: America/New_York
- id: EGLL
iata: LHR
icao: EGLL
name: London Heathrow
location: London, England
lat: 51.4775
lon: -0.4614
tz: Europe/London
#
aircraft:
- id: 1
subfleet_id: 1
name: Boeing 747-400
registration: NC17
tail_number: 17
- id: 2
subfleet_id: 2
name: Boeing 777-200
registration: NC20
tail_number: 20
#aircraft_rank:
# - aircraft_id: 1
# rank_id: 1
# - aircraft_id: 1
# rank_id: 2
# acars_pay: 100
# manual_pay: 50
fares:
- id: 1
code: Y
name: Economy
price: 100
capacity: 200
- id: 2
code: B
name: Business
price: 500
capacity: 10
- id: 3
code: F
name: First-Class
price: 800
capacity: 5
subfleets:
- id: 1
airline_id: 1
name: 747-400 Winglets
type: 744W
- id: 2
airline_id: 1
name: 777-200 LR
type: 772-LR
# add a few mods to aircraft and fares
subfleet_fare:
# Fare classes on the 747
- subfleet_id: 1
fare_id: 1
price: 200
capacity: 400
- subfleet_id: 1
fare_id: 2
capacity: 20
- subfleet_id: 1
fare_id: 3
price: 1000
capacity: 10
# Fare classes on the 777
- subfleet_id: 2
fare_id: 1
- subfleet_id: 2
fare_id: 3
capacity: 10
subfleet_flight:
- subfleet_id: 1
flight_id: flightid_1
flights:
- id: flightid_1
airline_id: 1
flight_number: 100
dpt_airport_id: KAUS
arr_airport_id: KJFK
route: KAUS KJFK
dpt_time: 6PM CST
arr_time: 11PM EST
- id: flightid_2
airline_id: 1
flight_number: 101
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 9AM EST
arr_time: 12PM CST
route: KJFK KAUS
- id: flightid_3
airline_id: 1
flight_number: 200
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 9AM EST
arr_time: 12PM CST
route: KJFK KAUS
- id: flightid_4
airline_id: 1
flight_number: 201
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 10AM EST
arr_time: 1PM CST
route: KJFK KAUS
- id: flightid_5
airline_id: 1
flight_number: 202
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 11AM EST
arr_time: 2PM CST
route: KJFK KAUS
- id: flightid_6
airline_id: 1
flight_number: 203
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 12PM EST
arr_time: 3PM CST
route: KJFK KAUS
- id: flightid_7
airline_id: 1
flight_number: 204
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 1PM EST
arr_time: 4PM CST
route: KJFK KAUS
- id: flightid_8
airline_id: 1
flight_number: 205
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 2PM EST
arr_time: 5PM CST
route: KJFK KAUS
- id: flightid_9
airline_id: 1
flight_number: 206
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 3PM EST
arr_time: 6PM CST
route: KJFK KAUS
- id: flightid_10
airline_id: 1
flight_number: 207
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 4PM EST
arr_time: 7PM CST
route: KJFK KAUS
- id: flightid_11
airline_id: 1
flight_number: 208
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 5PM EST
arr_time: 8PM CST
route: KJFK KAUS
- id: flightid_12
airline_id: 1
flight_number: 209
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 6PM EST
arr_time: 9PM CST
route: KJFK KAUS
- id: flightid_13
airline_id: 1
flight_number: 210
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 7PM EST
arr_time: 10PM CST
route: KJFK KAUS
- id: flightid_14
airline_id: 1
flight_number: 211
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 8PM EST
arr_time: 11PM CST
route: KJFK KAUS
- id: flightid_15
airline_id: 1
flight_number: 212
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_time: 9PM EST
arr_time: 12AM CST
route: KJFK KAUS
flight_fields:
- id: 1
flight_id: flightid_1
name: cost index
value: 80
- id: 2
flight_id: flightid_2
name: cost index
value: 100
user_bids:
- id: 100
user_id: 1
flight_id: flightid_1
- id: 101
user_id: 1
flight_id: flightid_3
pireps:
- id: pirepid_1
user_id: 1
airline_id: 1
flight_id: flightid_1
aircraft_id: 1
dpt_airport_id: KAUS
arr_airport_id: KJFK
flight_time: 21600 # 6 hours
status: 0
notes: just a pilot report
- id: pirepid_2
user_id: 1
airline_id: 1
flight_id: flightid_2
aircraft_id: 1
dpt_airport_id: KJFK
arr_airport_id: KAUS
flight_time: 21600 # 6 hours
status: 0
notes: just a pilot report
- id: pirepid_3
user_id: 1
airline_id: 1
flight_id: flightid_2
aircraft_id: 1
dpt_airport_id: KJFK
arr_airport_id: KAUS
flight_time: 21600 # 6 hours
status: 0
notes: just a pilot report
pirep_fields:
- id: 1
name: arrival gate
required: 0
pirep_field_values:
- id: 1
pirep_id: pirepid_1
name: arrival gate
value: B14
source: manual

View File

@@ -0,0 +1,9 @@
#
# Initial minimal data required. You probably don't
# want to modify or erase any of this here
#
ranks:
- id: 1
name: New Pilot
hours: 0

View File

@@ -52,7 +52,7 @@ class RouteServiceProvider extends ServiceProvider
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
require app_path('Routes/web.php');
});
}
@@ -74,7 +74,7 @@ class RouteServiceProvider extends ServiceProvider
'prefix' => 'api',
'as' => 'api.',
], function ($router) {
require base_path('routes/api.php');
require app_path('Routes/api.php');
});
}
}

50
app/Routes/admin.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
/**
* Admin Routes
*/
Route::group([
'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.',
'middleware' => ['role:admin'],
], function () {
Route::resource('airlines', 'AirlinesController');
Route::match(['get', 'put'], 'airports/fuel', 'AirportController@fuel');
Route::resource('airports', 'AirportController');
Route::resource('fares', 'FareController');
# subfleet
Route::resource('subfleets', 'SubfleetController');
Route::match(['get', 'post', 'put', 'delete'], 'subfleets/{id}/fares', 'SubfleetController@fares');
# aircraft and fare associations
Route::resource('aircraft', 'AircraftController');
# flights and aircraft associations
Route::resource('flights', 'FlightController');
Route::match(['get', 'post', 'put', 'delete'], 'flights/{id}/fields', 'FlightController@fields');
Route::match(['get', 'post', 'put', 'delete'], 'flights/{id}/subfleets', 'FlightController@subfleets');
# rankings
Route::resource('ranks', 'RankController');
Route::match(['get', 'post', 'put', 'delete'], 'ranks/{id}/subfleets', 'RankController@subfleets');
# view/update settings
Route::match(['get'], 'settings', 'SettingsController@index');
Route::match(['post', 'put'], 'settings', 'SettingsController@update');
# pirep related routes
Route::resource('pireps', 'PirepController');
Route::match(['get'], 'pireps/pending', 'PirepController@pending');
Route::match(['post', 'put'], 'pireps/{id}/status', 'PirepController@status');
Route::resource('pirepfields', 'PirepFieldController');
Route::resource('users', 'UserController');
# defaults
Route::get('', ['uses' => 'DashboardController@index']);
Route::get('/', ['uses' => 'DashboardController@index']);
Route::get('/dashboard', ['uses' => 'DashboardController@index', 'name' => 'dashboard']);
});

33
app/Routes/api.php Executable file
View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::group([], function ()
{
Route::match(['get'], 'status', 'BaseController@status');
Route::match(['get'], 'airports/{id}', 'AirportController@get');
Route::match(['get'], 'airports/{id}/lookup', 'AirportController@lookup');
Route::match(['get'], 'flights/search', 'FlightController@search');
Route::match(['get'], 'flights/{id}', 'FlightController@get');
Route::match(['get'], 'pirep/{id}', 'PirepController@get');
# This is the info of the user whose token is in use
Route::match(['get'], 'user', 'UserController@index');
#Route::match(['get'], 'user/bids', 'UserController@index');
Route::match(['get'], 'users/{id}', 'UserController@get');
Route::match(['get'], 'users/{id}/bids', 'UserController@bids');
});

18
app/Routes/console.php Executable file
View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Foundation\Inspiring;
/*
|--------------------------------------------------------------------------
| Console Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of your Closure based console
| commands. Each Closure is bound to a command instance allowing a
| simple approach to interacting with each command's IO methods.
|
*/
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
});

35
app/Routes/web.php Executable file
View File

@@ -0,0 +1,35 @@
<?php
Route::get('/', 'HomeController@index')->name('home');
/**
* User doesn't need to be logged in for these
*/
Route::group([
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.'
], function() {
Route::get('/r/{id}', 'PirepController@show')->name('pirep.show.public');
Route::get('/p/{id}', 'ProfileController@show')->name('profile.show.public');
});
/**
* These are only visible to a logged in user
*/
Route::group([
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.',
'middleware' => ['role:admin|user'],
], function () {
Route::resource('dashboard', 'DashboardController');
Route::get('flights/search', 'FlightController@search')->name('flights.search');
Route::match(['post'], '/flights/save', 'FlightController@save')->name('flights.save');
Route::resource('flights', 'FlightController');
Route::resource('profile', 'ProfileController');
Route::resource('pireps', 'PirepController');
});
Auth::routes();
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');
require app_path('Routes/admin.php');