From fce6c987fdbd7a9a6d17afc5aa88d62591b86322 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Wed, 3 Jan 2018 12:58:38 -0600 Subject: [PATCH] Add some stats info for airlines and the stats table #108 --- ...017_06_08_191703_create_airlines_table.php | 2 + .../2018_01_03_014930_create_stats_table.php | 62 +++++++++++++++++++ app/Models/Airline.php | 6 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 app/Database/migrations/2018_01_03_014930_create_stats_table.php diff --git a/app/Database/migrations/2017_06_08_191703_create_airlines_table.php b/app/Database/migrations/2017_06_08_191703_create_airlines_table.php index c5f8b70b..a7180a23 100644 --- a/app/Database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/app/Database/migrations/2017_06_08_191703_create_airlines_table.php @@ -21,6 +21,8 @@ class CreateAirlinesTable extends Migration $table->string('country', 2)->nullable(); $table->string('logo', 255)->nullable(); $table->boolean('active')->default(true); + $table->unsignedBigInteger('total_flights')->default(0); + $table->unsignedBigInteger('total_time')->default(0); $table->timestamps(); $table->index('icao'); diff --git a/app/Database/migrations/2018_01_03_014930_create_stats_table.php b/app/Database/migrations/2018_01_03_014930_create_stats_table.php new file mode 100644 index 00000000..e69763aa --- /dev/null +++ b/app/Database/migrations/2018_01_03_014930_create_stats_table.php @@ -0,0 +1,62 @@ +string('id'); + $table->string('value'); + $table->unsignedInteger('order'); + $table->string('type')->nullable(); + $table->string('description')->nullable(); + + $table->primary('id'); + $table->timestamps(); + }); + + $this->addCounterGroups([ + 'flights' => 1, + ]); + + /** + * Initial default settings + */ + $stats = [ + [ + 'id' => $this->formatSettingId('flights.total_flights'), + 'order' => $this->getNextOrderNumber('flights'), + 'value' => 0, + 'type' => 'int', + 'description' => 'Total number of flights in the VA', + ], + [ + 'id' => $this->formatSettingId('flights.total_time'), + 'order' => $this->getNextOrderNumber('flights'), + 'value' => 0, + 'type' => 'int', + 'description' => 'Total number of hours in the VA', + ], + ]; + + $this->addData('stats', $stats); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('settings'); + } +} diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 403cf2d6..f3fd0825 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -16,6 +16,8 @@ class Airline extends BaseModel 'name', 'logo', 'country', + 'total_flights', + 'total_time', 'active', ]; @@ -25,7 +27,9 @@ class Airline extends BaseModel * @var array */ protected $casts = [ - 'active' => 'boolean', + 'total_flights' => 'int', + 'total_time' => 'int', + 'active' => 'boolean', ]; /**