Skip to content

Commit

Permalink
Merge branch 'dev' into bug-fix-nabeelio#1275
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Aug 11, 2023
2 parents be0cbb1 + 9081bdb commit 5404840
Show file tree
Hide file tree
Showing 232 changed files with 4,619 additions and 3,711 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-versions: ['8.0', '8.1']
php-versions: ['8.1', '8.2']
name: PHP ${{ matrix.php-versions }}
env:
extensions: intl, pcov, mbstring
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'

- uses: olegtarasov/get-tag@v2.1
id: tagName
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1

- uses: olegtarasov/get-tag@v2.1
id: tagName
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A full distribution, with all of the composer dependencies, is available at this
1. Upload to your server
1. Visit the site, and follow the link to the installer

[View installation details](https://docs.phpvms.net/installation/installation)
[View installation details](https://docs.phpvms.net/installation)

## Development Environment with Docker

Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/DevCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle()

if (!$command) {
$this->error('No command specified!');
exit();
exit;
}

$commands = [
Expand All @@ -68,7 +68,7 @@ public function handle()

if (!array_key_exists($command, $commands)) {
$this->error('Command not found!');
exit();
exit;
}

$this->{$commands[$command]}();
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function getMetar(): void
$icao = $this->argument('param');
if (!$icao) {
$this->error('Enter an ICAO!');
exit();
exit;
}

$airportSvc = app(AirportService::class);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/PirepExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle()
$pirep_id = $this->argument('id');
if (empty($pirep_id)) {
$this->error('No PIREP ID specified');
exit();
exit;
}

// List the tables to export and the column name for the pirep id
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/YamlExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function handle()
$tables = $this->argument('tables');
if (empty($tables)) {
$this->error('No tables specified');
exit();
exit;
}

// A "preset" for exporting the base set of data
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/YamlImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function handle()
$files = $this->argument('files');
if (empty($files)) {
$this->error('No files to import specified!');
exit();
exit;
}

$ignore_errors = true;
Expand Down
3 changes: 3 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ protected function schedule(Schedule $schedule): void
->withoutOverlapping();
}

// Laravel 10 redis cache
$schedule->command('cache:prune-stale-tags')->hourly();

/*
* NOTE: IF MORE TASKS ARE ADDED, THEY ALSO MUST BE ADDED TO THE CRON.PHP
*/
Expand Down
3 changes: 2 additions & 1 deletion app/Contracts/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace App\Contracts;

use Illuminate\Support\Facades\Log;
use function is_array;
use Symfony\Component\Process\Process;

use function is_array;

/**
* Class BaseCommand
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Contracts/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getFromReq($request, $attrs_or_validations, $addtl_fields = null
/**
* Simple normalized method for forming the JSON responses
*
* @param $message
* @param $message
* @param null|mixed $count
* @param mixed $attrs
*
Expand Down
3 changes: 2 additions & 1 deletion app/Contracts/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use Exception;
use Illuminate\Validation\Validator;
use function is_array;
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Exceptions\RepositoryException;

use function is_array;

/**
* @mixin BaseRepository
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Contracts/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function offsetGet($unit): ?float
* @param $offset
* @param $value
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
// $this->units[$offset] = $value;
}
Expand All @@ -153,7 +153,7 @@ public function offsetSet($offset, $value)
*
* @param $offset
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
// $this->units[$offset] = null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('callsign')->nullable()->after('pilot_id');
});
}
};
36 changes: 36 additions & 0 deletions app/Database/migrations/2022_12_27_192218_create_events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

// Add events table and update flights & pirep tables for references
return new class() extends Migration {
public function up()
{
// Create events table
Schema::create('events', function (Blueprint $table) {
$table->integer('id');
$table->unsignedInteger('type')->default(0);
$table->string('name', 250);
$table->text('description')->nullable();
$table->date('start_date');
$table->date('end_date');
$table->boolean('active')->default(false)->nullable();
$table->timestamps();
// Add index
$table->primary('id');
});

// Update flights table
Schema::table('flights', function (Blueprint $table) {
$table->unsignedInteger('event_id')->nullable()->after('visible');
$table->unsignedInteger('user_id')->nullable()->after('event_id');
});

// Update pireps table
Schema::table('pireps', function (Blueprint $table) {
$table->unsignedInteger('event_id')->nullable()->after('aircraft_id');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('lastlogin_at')->nullable()->after('last_ip');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use App\Contracts\Migration;
use App\Models\Enums\FareType;
use App\Models\PirepFare;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
Schema::table('pirep_fares', function (Blueprint $table) {
$table->unsignedBigInteger('fare_id')->nullable()->change();
$table->string('code')->nullable();
$table->string('name')->nullable();
$table->unsignedDecimal('price')->nullable()->default(0.00);
$table->unsignedDecimal('cost')->nullable()->default(0.00);
$table->unsignedInteger('capacity')->nullable()->default(0);
$table->unsignedTinyInteger('type')
->default(FareType::PASSENGER)
->nullable()
->after('capacity');
});

/**
* Update all of the existing PIREP fares to include the existing fare info
*/
$all_fares = PirepFare::with('fare')->get();
/** @var PirepFare $fare */
foreach ($all_fares as $fare) {
if (empty($fare->fare)) {
continue;
}

$fare->code = $fare->fare->code;
$fare->name = $fare->fare->name;
$fare->capacity = $fare->fare->capacity;
$fare->price = $fare->fare->price;
$fare->cost = $fare->fare->cost;
$fare->type = $fare->fare->type;
$fare->fare_id = null;

$fare->save();
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use App\Contracts\Migration;
use App\Models\PirepFare;

/**
* Check if the PIREP fare has an empty capacity and update it from the subfleet
*/
return new class() extends Migration {
public function up()
{
$cached = [];
$fareSvc = app(App\Services\FareService::class);
$all_fares = PirepFare::with('pirep', 'pirep.aircraft', 'pirep.aircraft.subfleet')->get();

/** @var PirepFare $fare */
foreach ($all_fares as $fare) {
if (empty($fare->pirep) || !empty($fare->capacity)) { // has capacity, skip
continue;
}

// look up the subfleet
$subfleet = $fare->pirep->aircraft->subfleet;
if (empty($subfleet)) {
continue;
}

if (empty($cached[$subfleet->id])) {
$cached[$subfleet->id] = $fareSvc->getForSubfleet($subfleet);
}

/** @var \App\Models\Fare $sf */
$sf = $cached[$subfleet->id]->where('code', $fare->code)->first();
$fare->capacity = empty($sf) ? $fare->count : $sf->capacity;
$fare->save();
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

// Adds deleted_at fields to tables with SoftDelete trait
return new class() extends Migration {
public function up()
{
// Aircraft
Schema::table('aircraft', function (Blueprint $table) {
$table->softDeletes();
});

// Airline
Schema::table('airlines', function (Blueprint $table) {
$table->softDeletes();
});

// Airport
Schema::table('airports', function (Blueprint $table) {
$table->softDeletes();
});

// Award
Schema::table('awards', function (Blueprint $table) {
$table->softDeletes();
});

// Fare
Schema::table('fares', function (Blueprint $table) {
$table->softDeletes();
});

// Flight
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});

// Pirep
Schema::table('pireps', function (Blueprint $table) {
$table->softDeletes();
});

// Rank
Schema::table('ranks', function (Blueprint $table) {
$table->softDeletes();
});

// Subfleet
Schema::table('subfleets', function (Blueprint $table) {
$table->softDeletes();
});

// User table already have required field
// Schema::table('users', function (Blueprint $table) { $table->softDeletes(); });
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
Schema::table('pirep_fields', function (Blueprint $table) {
$table->string('description')->nullable()->after('slug');
});
}
};
14 changes: 14 additions & 0 deletions app/Database/migrations/2023_06_24_211137_add_fin_to_aircraft.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->string('fin', 5)->unique()->nullable()->after('registration');
});
}
};
Loading

0 comments on commit 5404840

Please sign in to comment.