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

@@ -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');
}
}