Compare commits

..

1 Commits

Author SHA1 Message Date
snyk-bot
52a43acb1a
fix: package.json & package-lock.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908
2021-09-12 22:33:09 +00:00
538 changed files with 16781 additions and 34227 deletions

View File

@ -15,10 +15,7 @@ declare -a remove_files=(
.idea
.travis
docker
node_modules
vendor/willdurand/geocoder/tests
_ide_helper.php
.env
.dockerignore
.dpl
.editorconfig
@ -26,7 +23,6 @@ declare -a remove_files=(
.eslintrc
.php_cs
.php_cs.cache
.php-cs-fixer.php
.phpstorm.meta.php
.styleci.yml
.phpunit.result.cache
@ -41,8 +37,9 @@ declare -a remove_files=(
phpvms.iml
Procfile
phpstan.neon
symfony.lock
node_modules
composer.phar
vendor/willdurand/geocoder/tests
)
for file in "${remove_files[@]}"; do

View File

@ -2,12 +2,12 @@ name: 'Build'
on: ['push', 'pull_request', 'workflow_dispatch', 'release']
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-18.04
if: github.repository == 'nabeelio/phpvms'
strategy:
fail-fast: true
matrix:
php-versions: ['8.0', '8.1']
php-versions: ['7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-versions }}
env:
extensions: intl, pcov, mbstring
@ -69,7 +69,6 @@ jobs:
run: |
php --version
mysql --version
sleep 15
# Downgrade composer version to 1.x
composer install --dev --no-interaction --verbose
cp .github/scripts/env.php env.php
@ -79,8 +78,7 @@ jobs:
- name: Run Tests
run: |
export PHP_CS_FIXER_IGNORE_ENV=1
#vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no
vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no
vendor/bin/phpunit --debug --verbose
# This runs after all of the tests, run have run. Creates a cleaned up version of the
@ -88,7 +86,7 @@ jobs:
artifacts:
name: 'Create dev build'
needs: build
runs-on: ubuntu-20.04
runs-on: 'ubuntu-18.04'
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
steps:
- name: Checkout
@ -97,7 +95,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '7.4'
- uses: olegtarasov/get-tag@v2.1
id: tagName
@ -150,7 +148,7 @@ jobs:
release:
name: 'Create Release'
needs: build
runs-on: ubuntu-20.04
runs-on: 'ubuntu-18.04'
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
@ -159,7 +157,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: '7.4'
- uses: olegtarasov/get-tag@v2.1
id: tagName

12
.gitignore vendored
View File

@ -22,7 +22,6 @@ storage/*.sqlite
.env.*.php
.env.php
.env
.env.*
.env.bak
env.php
.env.generated
@ -77,14 +76,3 @@ error_log
/config.php
/config.bak.php
/VERSION
sync.sh
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

View File

@ -1,69 +0,0 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
$header = <<<'EOF'
This file is part of PHP CS Fixer.
(c) Fabien Potencier <fabien@symfony.com>
Dariusz Rumiński <dariusz.ruminski@gmail.com>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;
$finder = PhpCsFixer\Finder::create()
->ignoreVCSIgnored(true)
->exclude('tests/data')
->exclude('storage')
->exclude('resources')
->in(__DIR__)
->append([
__DIR__.'/dev-tools/doc.php',
// __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
__FILE__,
])
;
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'strict_param' => true,
'no_php4_constructor' => true,
'no_extra_blank_lines' => true,
'no_superfluous_elseif' => true,
'single_line_comment_style' => false,
'simple_to_complex_string_variable' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align_single_space_minimal'
]
],
/*
'blank_line_before_statement' => [
'statements' => [
'declare',
'for',
'return',
'throw',
'try',
],
],
*/
])
->setFinder($finder);
return $config;

37
.php_cs Normal file
View File

@ -0,0 +1,37 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in('app')
->in('config');
return PhpCsFixer\Config::create()
->setHideProgress(true)
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'strict_param' => true,
'no_php4_constructor' => true,
'no_extra_blank_lines' => true,
'no_superfluous_elseif' => true,
'single_line_comment_style' => false,
'simple_to_complex_string_variable' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'align_double_arrow' => true,
],
/*
'blank_line_before_statement' => [
'statements' => [
'declare',
'for',
'return',
'throw',
'try',
],
],
*/
])
->setFinder($finder);

View File

@ -1,15 +1,14 @@
FROM php:8.1-fpm-alpine3.15
FROM php:7.4-fpm-alpine
WORKDIR /var/www/
# Setup composer
COPY --from=composer:2.2.7 /usr/bin/composer /usr/local/bin/composer
RUN apk add gmp-dev icu-dev zlib-dev libpng-dev libzip-dev zip
RUN apk add gmp-dev icu-dev zlib-dev libpng-dev
RUN curl --silent --show-error https://getcomposer.org/installer | php
# Copy any config files in
COPY resources/docker/php/ext-opcache.ini $PHP_INI_DIR/conf.d/
COPY resources/docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
RUN ln -sf /dev/stderr /var/log/fpm-error.log
RUN docker-php-ext-install \
calendar \
@ -17,19 +16,17 @@ RUN docker-php-ext-install \
pdo_mysql \
gd \
gmp \
bcmath \
opcache \
zip && \
docker-php-ext-enable pdo_mysql opcache bcmath zip intl
opcache && \
docker-php-ext-enable pdo_mysql opcache
COPY . /var/www/
RUN composer install \
RUN php composer.phar install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist
#RUN chown -R www-data:www-data /var/www
RUN chown -R www-data:www-data /var/www
EXPOSE 9000

View File

@ -80,7 +80,7 @@ test:
.PHONY: phpcs
phpcs:
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no
@vendor/bin/php-cs-fixer fix --config=.php_cs -v --diff --diff-format=udiff --dry-run
.PHONY: replay-acars
replay-acars:
@ -102,7 +102,7 @@ reset-installer:
.PHONY: docker-test
docker-test:
@docker compose -f docker-compose.dev.yml up
@docker-compose -f docker-compose.yml -f docker-compose.local.yml up
.PHONY: docker-clean
docker-clean:

View File

@ -11,7 +11,7 @@ A full distribution, with all of the composer dependencies, is available at this
### Requirements
- PHP 8.0+, extensions:
- PHP 7.3+, extensions:
- cURL
- JSON
- mbstring
@ -39,7 +39,7 @@ make docker-test
# **OR** with docker-compose directly
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
docker-compose -f docker-compose.yml -f docker-compose.local.yml up
```
Then go to `http://localhost`. If you're using dnsmasq, the `app` container is listening on `phpvms.test`, or you can add to your `/etc/hosts` file:

View File

@ -17,25 +17,25 @@ class AcarsReplay extends Command
*
* @var string
*/
protected string $apiKey = 'testadminapikey';
protected $apiKey = 'testadminapikey';
/**
* For automatic updates, how many seconds to sleep between updates
*
* @var int
*/
protected int $sleepTime = 10;
protected $sleepTime = 10;
/**
* @var array key == update[callsign]
* value == PIREP ID
*/
protected array $pirepList = [];
protected $pirepList = [];
/**
* @var Client
*/
protected Client $httpClient;
protected $httpClient;
/**
* Return an instance of an HTTP client all ready to post

View File

@ -2,11 +2,11 @@
namespace App\Console\Commands;
use App;
use App\Contracts\Command;
use App\Services\Installer\ConfigService;
use App\Services\Installer\SeederService;
use DatabaseSeeder;
use Illuminate\Support\Facades\App;
/**
* Create the config files
@ -16,8 +16,8 @@ class CreateConfigs extends Command
protected $signature = 'phpvms:config {db_host} {db_name} {db_user} {db_pass}';
protected $description = 'Create the config files';
private DatabaseSeeder $databaseSeeder;
private SeederService $seederSvc;
private $databaseSeeder;
private $seederSvc;
public function __construct(DatabaseSeeder $databaseSeeder, SeederService $seederSvc)
{

View File

@ -11,11 +11,7 @@ class CreateDatabase extends Command
{
protected $signature = 'database:create {--reset} {--migrate} {--conn=?}';
protected $description = 'Create a database';
/**
* @var Detector
*/
protected Detector $os;
protected $os;
/**
* CreateDatabase constructor.

View File

@ -24,8 +24,7 @@ class DevCommands extends Command
{
protected $signature = 'phpvms {cmd} {param?}';
protected $description = 'Developer commands';
protected DatabaseService $dbSvc;
protected $dbSvc;
/**
* DevCommands constructor.

View File

@ -13,7 +13,7 @@ class DevInstall extends Command
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
protected $description = 'Run a developer install and run the sample migration';
private \DatabaseSeeder $databaseSeeder;
private $databaseSeeder;
public function __construct(\DatabaseSeeder $databaseSeeder)
{

View File

@ -10,7 +10,7 @@ class ImportCsv extends Command
protected $signature = 'phpvms:csv-import {type} {file}';
protected $description = 'Import from a CSV file';
private ImportService $importer;
private $importer;
/**
* Import constructor.

View File

@ -18,15 +18,11 @@ class ProcessQueue extends Command
public function handle()
{
Artisan::call('queue:work', [
//'--sansdaemon' => null,
'--sansdaemon' => null,
'--stop-when-empty' => null,
]);
$jobOutput = trim(Artisan::output());
if (!empty($jobOutput)) {
Log::info($jobOutput);
}
Log::info(Artisan::output());
///** @var App\Support\WorkCommand $queueWorker */
//$queueWorker = new App\Support\WorkCommand(app('queue.worker'), app('cache.store'));

View File

@ -8,11 +8,7 @@ use GuzzleHttp\Client;
class TestApi extends Command
{
protected $signature = 'phpvms:test-api {apikey} {url}';
/**
* @var Client
*/
protected Client $httpClient;
protected $httpClient;
/**
* Run dev related commands

View File

@ -10,14 +10,8 @@ class Version extends Command
{
protected $signature = 'phpvms:version {--write} {--base-only} {--write-full-version} {version?}';
/**
* @var VersionService
*/
private VersionService $versionSvc;
private $versionSvc;
/**
* @param VersionService $versionSvc
*/
public function __construct(VersionService $versionSvc)
{
parent::__construct();

View File

@ -12,11 +12,7 @@ class YamlImport extends Command
{
protected $signature = 'phpvms:yaml-import {files*}';
protected $description = 'Developer commands';
/**
* @var DatabaseService
*/
protected DatabaseService $dbSvc;
protected $dbSvc;
/**
* YamlImport constructor.

View File

@ -1,90 +0,0 @@
<?php
/**
* This runs any of the cron tasks that are set to run according to the Laravel schedule
*/
namespace App\Console;
use App\Console\Cron\FifteenMinute;
use App\Console\Cron\FiveMinute;
use App\Console\Cron\Hourly;
use App\Console\Cron\JobQueue;
use App\Console\Cron\Monthly;
use App\Console\Cron\Nightly;
use App\Console\Cron\ThirtyMinute;
use App\Console\Cron\Weekly;
use App\Contracts\Command;
use Illuminate\Console\Scheduling\Schedule;
class Cron
{
/** @var Schedule */
private $scheduler;
/**
* @var string[] The cron tasks which get called/run
*/
private $cronTasks = [
JobQueue::class,
FiveMinute::class,
FifteenMinute::class,
ThirtyMinute::class,
Hourly::class,
Nightly::class,
Weekly::class,
Monthly::class,
];
/**
* @var array Stores the instantiated cron tasks
*/
private $cronRunners = [];
/**
* @param Schedule $scheduler
*/
public function __construct(Schedule $scheduler)
{
$this->scheduler = $scheduler;
foreach ($this->cronTasks as $task) {
/** @var Command $cronTask */
$cronTask = app($task);
$signature = $cronTask->getSignature();
if (empty($signature)) {
continue;
}
$this->cronRunners[$signature] = $cronTask;
}
}
/**
* Try to figure out which commands are supposed to run right now
*
* @return array string of tasks that were run
*/
public function run(): array
{
$events = $this->scheduler->dueEvents(app());
if (empty($events)) {
return [];
}
$run = [];
/** @var \Illuminate\Console\Scheduling\Event $event */
foreach ($events as $event) {
foreach ($this->cronRunners as $signature => $task) {
if (!str_contains($event->command, $signature)) {
continue;
}
$task->callEvent();
$run[] = $signature;
}
}
return $run;
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Events\CronFifteenMinute;
/**
* The actual cron tasks are in app/Cron
*/
class FifteenMinute extends CronCommand
{
protected $signature = 'cron:fifteen';
protected $description = 'Run the 15 minute cron tasks';
protected $schedule;
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
event(new CronFifteenMinute());
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Events\CronFiveMinute;
/**
* This just calls the CronNightly event, so all of the
* listeners, etc can just be called to run those tasks
*
* The actual cron tasks are in app/Cron
*/
class FiveMinute extends CronCommand
{
protected $signature = 'cron:five';
protected $description = 'Run the 5 minute cron tasks';
protected $schedule;
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
event(new CronFiveMinute());
}
}

View File

@ -2,14 +2,14 @@
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Contracts\Command;
use App\Events\CronHourly;
/**
* This just calls the CronHourly event, so all of the
* listeners, etc can just be called to run those tasks
*/
class Hourly extends CronCommand
class Hourly extends Command
{
protected $signature = 'cron:hourly';
protected $description = 'Run the hourly cron tasks';
@ -17,11 +17,7 @@ class Hourly extends CronCommand
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
$this->redirectLoggingToFile('cron');
event(new CronHourly());
}
}

View File

@ -2,14 +2,14 @@
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Contracts\Command;
use Illuminate\Support\Facades\Artisan;
/**
* This just calls the CronHourly event, so all of the
* listeners, etc can just be called to run those tasks
*/
class JobQueue extends CronCommand
class JobQueue extends Command
{
protected $signature = 'cron:queue';
protected $description = 'Run the cron queue tasks';
@ -17,16 +17,9 @@ class JobQueue extends CronCommand
public function handle(): void
{
$this->callEvent();
$queueOutput = trim(Artisan::output());
if (!empty($queueOutput)) {
$this->info($queueOutput);
}
}
public function callEvent()
{
$this->redirectLoggingToFile('cron');
Artisan::call('queue:cron');
$this->info(Artisan::output());
}
}

View File

@ -2,7 +2,7 @@
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Contracts\Command;
use App\Events\CronMonthly;
/**
@ -11,7 +11,7 @@ use App\Events\CronMonthly;
*
* The actual cron tasks are in app/Cron
*/
class Monthly extends CronCommand
class Monthly extends Command
{
protected $signature = 'cron:monthly';
protected $description = 'Run the monthly cron tasks';
@ -19,11 +19,7 @@ class Monthly extends CronCommand
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
$this->redirectLoggingToFile('cron');
event(new CronMonthly());
}
}

View File

@ -2,7 +2,7 @@
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Contracts\Command;
use App\Events\CronNightly;
/**
@ -11,7 +11,7 @@ use App\Events\CronNightly;
*
* The actual cron tasks are in app/Cron
*/
class Nightly extends CronCommand
class Nightly extends Command
{
protected $signature = 'cron:nightly';
protected $description = 'Run the nightly cron tasks';
@ -19,11 +19,7 @@ class Nightly extends CronCommand
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
$this->redirectLoggingToFile('cron');
event(new CronNightly());
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Events\CronThirtyMinute;
/**
* The actual cron tasks are in app/Cron
*/
class ThirtyMinute extends CronCommand
{
protected $signature = 'cron:thirty';
protected $description = 'Run the 30 minute cron tasks';
protected $schedule;
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
event(new CronThirtyMinute());
}
}

View File

@ -2,7 +2,7 @@
namespace App\Console\Cron;
use App\Contracts\CronCommand;
use App\Contracts\Command;
use App\Events\CronWeekly;
/**
@ -11,7 +11,7 @@ use App\Events\CronWeekly;
*
* The actual cron tasks are in app/Cron
*/
class Weekly extends CronCommand
class Weekly extends Command
{
protected $signature = 'cron:weekly';
protected $description = 'Run the weekly cron tasks';
@ -19,11 +19,7 @@ class Weekly extends CronCommand
public function handle(): void
{
$this->callEvent();
}
public function callEvent()
{
$this->redirectLoggingToFile('cron');
event(new CronWeekly());
}
}

View File

@ -2,13 +2,10 @@
namespace App\Console;
use App\Console\Cron\FifteenMinute;
use App\Console\Cron\FiveMinute;
use App\Console\Cron\Hourly;
use App\Console\Cron\JobQueue;
use App\Console\Cron\Monthly;
use App\Console\Cron\Nightly;
use App\Console\Cron\ThirtyMinute;
use App\Console\Cron\Weekly;
use App\Services\CronService;
use Illuminate\Console\Scheduling\Schedule;
@ -36,16 +33,10 @@ class Kernel extends ConsoleKernel
->withoutOverlapping();
}
/*
* NOTE: IF MORE TASKS ARE ADDED, THEY ALSO MUST BE ADDED TO THE CRON.PHP
*/
$schedule->command(FiveMinute::class)->everyFiveMinutes();
$schedule->command(FifteenMinute::class)->everyFifteenMinutes();
$schedule->command(ThirtyMinute::class)->everyThirtyMinutes();
$schedule->command(Nightly::class)->dailyAt('01:00');
$schedule->command(Hourly::class)->hourly();
$schedule->command(Weekly::class)->weeklyOn(0);
$schedule->command(Monthly::class)->monthlyOn(1);
$schedule->command(Hourly::class)->hourly();
// When spatie-backups runs
/*if (config('backup.backup.enabled', false) === true) {

View File

@ -37,10 +37,10 @@ abstract class Award
*/
/** @var \App\Models\Award|null */
protected ?AwardModel $award;
protected $award;
/** @var \App\Models\User|null */
protected ?User $user;
protected $user;
public function __construct(AwardModel $award = null, User $user = null)
{
@ -69,9 +69,9 @@ abstract class Award
/**
* Add the award to this user, if they don't already have it
*
* @return bool|UserAward|null
* @return bool|UserAward
*/
protected function addAward(): bool|UserAward|null
protected function addAward()
{
$w = [
'user_id' => $this->user->id,

View File

@ -29,16 +29,6 @@ abstract class Command extends \Illuminate\Console\Command
}*/
}
/**
* Return the signature of the command
*
* @return string
*/
public function getSignature(): string
{
return $this->signature;
}
/**
* Splice the logger and replace the active handlers with the handlers from the
* a stack in config/logging.php

View File

@ -84,21 +84,19 @@ abstract class Controller extends \Illuminate\Routing\Controller
*
* @param $message
* @param null|mixed $count
* @param mixed $attrs
*
* @return \Illuminate\Http\JsonResponse
*/
public function message($message, $count = null, $attrs = [])
public function message($message, $count = null)
{
$ret = [
$attrs = [
'message' => $message,
'attrs' => $attrs,
];
if ($count !== null) {
$ret['count'] = $count;
$attrs['count'] = $count;
}
return response()->json($ret);
return response()->json($attrs);
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace App\Contracts;
abstract class CronCommand extends Command
{
/**
* @return mixed
*/
abstract public function callEvent();
/**
* Adjust the logging depending on where we're running from
*/
public function __construct()
{
parent::__construct();
$this->redirectLoggingToFile('cron');
}
}

View File

@ -7,14 +7,14 @@ namespace App\Contracts;
*/
abstract class Enum
{
protected static array $cache = [];
protected static array $codes = [];
protected static array $labels = [];
protected static $cache = [];
protected static $codes = [];
protected static $labels = [];
/**
* @var int
*/
protected int $value;
protected $value;
/**
* Create an instance of this Enum
@ -29,9 +29,9 @@ abstract class Enum
/**
* Return the value that's been set if this is an instance
*
* @return int|null
* @return mixed
*/
final public function getValue(): ?int
final public function getValue()
{
return $this->value;
}
@ -41,9 +41,9 @@ abstract class Enum
*
* @param $value
*
* @return string
* @return mixed
*/
final public static function label($value): string
final public static function label($value)
{
if (isset(static::$labels[$value])) {
$val = static::$labels[$value];
@ -53,8 +53,6 @@ abstract class Enum
return $val;
}
return $value;
}
/**
@ -89,11 +87,11 @@ abstract class Enum
*
* @return false|int|string
*/
public static function convertToCode($value): bool|int|string|null
public static function convertToCode($value)
{
$value = (int) $value;
if (!array_key_exists($value, static::$codes)) {
return null;
return;
}
return static::$codes[$value];

View File

@ -1,9 +0,0 @@
<?php
namespace App\Contracts;
use Illuminate\Database\Eloquent\Factories\Factory as EloquentFactory;
abstract class Factory extends EloquentFactory
{
}

View File

@ -166,27 +166,6 @@ class ImportExport
return [];
}
if (strpos($split_values[0], '?') !== false) {
// This contains the query string, which turns it into a multi-level array
$query_str = explode('?', $split_values[0]);
$parent = trim($query_str[0]);
$children = [];
$kvp = explode('&', trim($query_str[1]));
foreach ($kvp as $items) {
if (!$items) {
continue;
}
$this->kvpToArray($items, $children);
}
$ret[$parent] = $children;
return $ret;
}
// This is not a query string, return it back untouched
return [$split_values[0]];
}

View File

@ -2,6 +2,7 @@
namespace App\Contracts;
use App\Notifications\Channels\Discord\DiscordMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -25,4 +26,24 @@ class Notification extends \Illuminate\Notifications\Notification implements Sho
$this->channels = $notif_config[$klass];*/
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
/*public function via($notifiable)
{
return $this->channels;
}*/
/**
* @return DiscordMessage|null
*/
public function toDiscordChannel($notifiable): ?DiscordMessage
{
return null;
}
}

View File

@ -133,10 +133,7 @@ abstract class Repository extends BaseRepository
$page = (int) request()->query('page', 1);
$results = $this->model->{$method}($limit, $columns, 'page', $page);
$qs = request()->except(['page', 'user']);
$results->appends($qs);
$results->appends(app('request')->query());
$this->resetModel();
return $this->parserResult($results);

View File

@ -3,6 +3,7 @@
namespace App\Contracts;
use ArrayAccess;
use PhpUnitsOfMeasure\Exception\UnknownUnitOfMeasure;
/**
* Abstract unit wrapper
@ -10,89 +11,45 @@ use ArrayAccess;
class Unit implements ArrayAccess
{
/**
* The localized unit the user wants it displayed in
* The unit this is kept as
*/
public string $localUnit;
public $unit;
/**
* The unit that this value is stored in locally
* All of the units of this class
*/
public string $internalUnit;
/**
* All of the units of this class which are reported in an API response
*/
public array $units;
public $units;
/**
* Holds an instance of the PhpUnit type
*
* @var \PhpUnitsOfMeasure\AbstractPhysicalQuantity
*/
protected mixed $instance;
protected $instance;
/**
* Units that are included as part of the REST response
*/
public array $responseUnits = [];
public $responseUnits = [];
/**
* Factory method for creating a new unit type
*
* @param mixed $value
* @param string $unit
*
* @throws \Exception
*
* @return Unit
* @return mixed
*/
public static function make(mixed $value, string $unit): self
public function value()
{
if ($value instanceof self) {
return $value;
}
return new static($value, $unit);
}
/**
* Return the value in an internal format
*
* @param int|null $round Optional value to round to
*
* @return float|null
*/
public function internal(?int $round = null): ?float
{
return $this->toUnit($this->internalUnit, $round);
}
/**
* Return the value in the localized format
*
* @param int|null $round Optional value to round to
*
* @return float|null
*/
public function local(?int $round = null): ?float
{
return $this->toUnit($this->localUnit, $round);
return $this->__toString();
}
/**
* Just call toUnit() on the PhpUnitOfMeasure instance
*
* @param string $unit
* @param int|null $round Optional value to round to
* @param string $unit
*
* @return float|null
* @return mixed
*/
public function toUnit(string $unit, ?int $round = null): ?float
public function toUnit($unit)
{
$val = $this->instance->toUnit($unit);
if ($round === null) {
return $val;
}
return round($val, $round);
return $this->instance->toUnit($unit);
}
/**
@ -102,7 +59,7 @@ class Unit implements ArrayAccess
{
$response = [];
foreach ($this->responseUnits as $unit) {
$response[$unit] = round($this->instance->toUnit($unit), 2);
$response[$unit] = $this[$unit] ?? 0;
}
return $response;
@ -115,7 +72,7 @@ class Unit implements ArrayAccess
*
* @return bool
*/
public function offsetExists($offset): bool
public function offsetExists($offset)
{
return $this->offsetGet($offset) !== null;
}
@ -123,15 +80,19 @@ class Unit implements ArrayAccess
/**
* Implements ArrayAccess
*
* @param $unit
* @param $offset
*
* @return float|null
* @return mixed
*/
public function offsetGet($unit): ?float
public function offsetGet($offset)
{
$value = $this->instance->toUnit($unit);
if (!$value) {
return null;
try {
$value = $this->instance->toUnit($offset);
if (!$value) {
return;
}
} catch (UnknownUnitOfMeasure $e) {
return;
}
return round($value, 2);
@ -163,6 +124,6 @@ class Unit implements ArrayAccess
*/
public function __toString()
{
return (string) $this->offsetGet($this->localUnit);
return (string) $this->offsetGet($this->unit);
}
}

View File

@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
*/
class ClearExpiredSimbrief extends Listener
{
private SimBriefService $simbriefSvc;
private $simbriefSvc;
public function __construct(SimBriefService $simbriefSvc)
{
@ -20,7 +20,7 @@ class ClearExpiredSimbrief extends Listener
}
/**
* @param CronHourly $event
* @param \App\Events\CronNightly $event
*/
public function handle(CronHourly $event): void
{

View File

@ -6,7 +6,6 @@ use App\Contracts\Listener;
use App\Events\CronHourly;
use App\Events\PirepCancelled;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
@ -32,7 +31,6 @@ class RemoveExpiredLiveFlights extends Listener
$date = Carbon::now('UTC')->subHours(setting('acars.live_time'));
$pireps = Pirep::where('updated_at', '<', $date)
->where('state', PirepState::IN_PROGRESS)
->where('status', '<>', PirepStatus::PAUSED)
->get();
foreach ($pireps as $pirep) {

View File

@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log;
*/
class ApplyExpenses extends Listener
{
private RecurringFinanceService $financeSvc;
private $financeSvc;
/**
* ApplyExpenses constructor.

View File

@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log;
*/
class ApplyExpenses extends Listener
{
private RecurringFinanceService $financeSvc;
private $financeSvc;
/**
* ApplyExpenses constructor.

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
class NewVersionCheck extends Listener
{
private VersionService $versionSvc;
private $versionSvc;
/**
* @param VersionService $versionSvc

View File

@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
*/
class PilotLeave extends Listener
{
private UserService $userSvc;
private $userSvc;
/**
* PilotLeave constructor.

View File

@ -6,14 +6,14 @@ use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Models\Journal;
use App\Repositories\JournalRepository;
use Illuminate\Support\Facades\Log;
use Log;
/**
* This recalculates the balances on all of the journals
*/
class RecalculateBalances extends Listener
{
private JournalRepository $journalRepo;
private $journalRepo;
/**
* Nightly constructor.

View File

@ -13,8 +13,8 @@ use Illuminate\Support\Facades\Log;
*/
class RecalculateStats extends Listener
{
private AircraftService $aircraftSvc;
private UserService $userSvc;
private $aircraftSvc;
private $userSvc;
public function __construct(AircraftService $aircraftSvc, UserService $userSvc)
{

View File

@ -1,43 +1,23 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Acars;
use DateTime;
class AcarsFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Acars::class;
/**
* @return array <string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'pirep_id' => null,
'log' => $this->faker->text(100),
'lat' => $this->faker->latitude,
'lon' => $this->faker->longitude,
'distance' => $this->faker->randomFloat(2, 0, 6000),
'heading' => $this->faker->numberBetween(0, 359),
'altitude' => $this->faker->numberBetween(20, 400),
'vs' => $this->faker->numberBetween(-5000, 5000),
'gs' => $this->faker->numberBetween(300, 500),
'transponder' => $this->faker->numberBetween(200, 9999),
'autopilot' => $this->faker->text(10),
'fuel' => $this->faker->randomFloat(2, 100, 1000),
'fuel_flow' => $this->faker->randomFloat(2, 100, 1000),
'sim_time' => $this->faker->dateTime('now', 'UTC')->format(DateTime::ATOM),
];
}
}
$factory->define(App\Models\Acars::class, function (Faker $faker) {
return [
'id' => null,
'pirep_id' => null,
'log' => $faker->text(100),
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'distance' => $faker->randomFloat(2, 0, 6000),
'heading' => $faker->numberBetween(0, 359),
'altitude' => $faker->numberBetween(20, 400),
'vs' => $faker->numberBetween(-5000, 5000),
'gs' => $faker->numberBetween(300, 500),
'transponder' => $faker->numberBetween(200, 9999),
'autopilot' => $faker->text(10),
'fuel' => $faker->randomFloat(2, 100, 1000),
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
'sim_time' => $faker->dateTime('now', 'UTC'),
];
});

View File

@ -1,51 +1,33 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Aircraft;
use App\Models\Airport;
use App\Models\Enums\AircraftState;
use App\Models\Enums\AircraftStatus;
use App\Models\Subfleet;
use App\Support\ICAO;
use DateTime;
use Faker\Generator as Faker;
class AircraftFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Aircraft::class;
/**
* Define the model's default state.
*
* @throws \Exception
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'subfleet_id' => fn () => Subfleet::factory()->create()->id,
'airport_id' => fn () => Airport::factory()->create()->id,
'iata' => $this->faker->unique()->text(5),
'icao' => $this->faker->unique()->text(5),
'name' => $this->faker->text(50),
'registration' => $this->faker->unique()->text(10),
'hex_code' => ICAO::createHexCode(),
'mtow' => $this->faker->randomFloat(2, 0, 50000),
'zfw' => $this->faker->randomFloat(2, 0, 50000),
'status' => AircraftStatus::ACTIVE,
'state' => AircraftState::PARKED,
'created_at' => $this->faker->dateTimeBetween('-1 week')->format(DateTime::ATOM),
'updated_at' => fn (array $pirep) => $pirep['created_at'],
];
}
}
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
return [
'id' => null,
'subfleet_id' => function () {
return factory(Subfleet::class)->create()->id;
},
'airport_id' => function () {
return factory(Airport::class)->create()->id;
},
'iata' => $faker->unique()->text(5),
'icao' => $faker->unique()->text(5),
'name' => $faker->text(50),
'registration' => $faker->unique()->text(10),
'hex_code' => ICAO::createHexCode(),
'mtow' => $faker->randomFloat(2, 0, 50000),
'zfw' => $faker->randomFloat(2, 0, 50000),
'status' => AircraftStatus::ACTIVE,
'state' => AircraftState::PARKED,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $pirep) {
return $pirep['created_at'];
},
];
});

View File

@ -1,41 +1,25 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Airline;
use Faker\Generator as Faker;
use Hashids\Hashids;
class AirlineFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Airline::class;
/*
* Add any number of airports. Don't really care if they're real or not
*/
$factory->define(App\Models\Airline::class, function (Faker $faker) {
return [
'id' => null,
'icao' => function (array $apt) {
$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'icao' => function (array $apt): string {
$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));
return $hashids->encode($mt);
},
'iata' => fn (array $apt) => $apt['icao'],
'name' => $this->faker->sentence(3),
'country' => $this->faker->country,
'active' => 1,
];
}
}
return $hashids->encode($mt);
},
'iata' => function (array $apt) {
return $apt['icao'];
},
'name' => $faker->sentence(3),
'country' => $faker->country,
'active' => 1,
];
});

View File

@ -1,31 +1,12 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Airport;
class AirportFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Airport::class;
protected array $usedIcaos = [];
/**
* Generate a fake ICAO
*
* @throws \Exception
*
* @return string
*/
protected function createFactoryICAO(): string
/*
* Create an ICAO for use in the factory.
*/
if (!function_exists('createFactoryICAO')) {
function createFactoryICAO(): string
{
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$max = strlen($characters) - 1;
@ -39,35 +20,37 @@ class AirportFactory extends Factory
return $string;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => function () {
do {
$airport = $this->createFactoryICAO();
} while (in_array($airport, $this->usedIcaos, true));
return $airport;
},
'icao' => fn (array $apt) => $apt['id'],
'iata' => fn (array $apt) => $apt['id'],
'name' => $this->faker->sentence(3),
'country' => $this->faker->country,
'timezone' => $this->faker->timezone,
'lat' => $this->faker->latitude,
'lon' => $this->faker->longitude,
'hub' => false,
'notes' => null,
'ground_handling_cost' => $this->faker->randomFloat(2, 0, 500),
'fuel_100ll_cost' => $this->faker->randomFloat(2, 1, 10),
'fuel_jeta_cost' => $this->faker->randomFloat(2, 1, 10),
'fuel_mogas_cost' => $this->faker->randomFloat(2, 1, 10),
];
}
}
/*
* Add any number of airports. Don't really care if they're real or not
*/
$factory->define(App\Models\Airport::class, function (Faker $faker) {
$usedIcaos = [];
return [
'id' => function () use ($usedIcaos) {
do {
$airport = createFactoryICAO();
} while (in_array($airport, $usedIcaos, true));
return $airport;
},
'icao' => function (array $apt) {
return $apt['id'];
},
'iata' => function (array $apt) {
return $apt['id'];
},
'name' => $faker->sentence(3),
'country' => $faker->country,
'timezone' => $faker->timezone,
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'hub' => false,
'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
'fuel_100ll_cost' => $faker->randomFloat(2, 1, 10),
'fuel_jeta_cost' => $faker->randomFloat(2, 1, 10),
'fuel_mogas_cost' => $faker->randomFloat(2, 1, 10),
];
});

View File

@ -1,34 +0,0 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Award;
class AwardFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Award::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'name' => $this->faker->name,
'description' => $this->faker->text(10),
'ref_model' => null,
'ref_model_params' => null,
];
}
}

View File

@ -0,0 +1,13 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Award::class, function (Faker $faker) {
return [
'id' => null,
'name' => $faker->name,
'description' => $faker->text(10),
'ref_model' => null,
'ref_model_params' => null,
];
});

View File

@ -1,39 +1,18 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Enums\ExpenseType;
use App\Models\Expense;
use Faker\Generator as Faker;
class ExpenseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Expense::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'airline_id' => null,
'name' => $this->faker->text(20),
'amount' => $this->faker->randomFloat(2, 100, 1000),
'type' => ExpenseType::FLIGHT,
'multiplier' => false,
'ref_model' => \App\Models\Expense::class,
'ref_model_id' => null,
'active' => true,
];
}
}
$factory->define(App\Models\Expense::class, function (Faker $faker) {
return [
'id' => null,
'airline_id' => null,
'name' => $faker->text(20),
'amount' => $faker->randomFloat(2, 100, 1000),
'type' => ExpenseType::FLIGHT,
'multiplier' => false,
'ref_model' => \App\Models\Expense::class,
'ref_model_id' => null,
'active' => true,
];
});

View File

@ -1,35 +1,16 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Fare;
class FareFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Fare::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'code' => $this->faker->unique()->text(50),
'name' => $this->faker->text(50),
'price' => $this->faker->randomFloat(2, 100, 1000),
'cost' => fn (array $fare) => round($fare['price'] / 2),
'capacity' => $this->faker->randomFloat(0, 20, 500),
];
}
}
$factory->define(App\Models\Fare::class, function (Faker $faker) {
return [
'id' => null,
'code' => $faker->unique()->text(50),
'name' => $faker->text(50),
'price' => $faker->randomFloat(2, 100, 1000),
'cost' => function (array $fare) {
return round($fare['price'] / 2);
},
'capacity' => $faker->randomFloat(0, 20, 500),
];
});

View File

@ -1,58 +1,44 @@
<?php
/**
* Create flights
*/
use Faker\Generator as Faker;
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Flight;
use DateTime;
class FlightFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Flight::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => $this->faker->unique()->numberBetween(10, 10000000),
'airline_id' => fn () => \App\Models\Airline::factory()->create()->id,
'flight_number' => $this->faker->unique()->numberBetween(10, 1000000),
'route_code' => $this->faker->randomElement(['', $this->faker->text(5)]),
'route_leg' => $this->faker->randomElement(
['', $this->faker->numberBetween(0, 1000)]
),
'dpt_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
'arr_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
'alt_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
'distance' => $this->faker->numberBetween(1, 1000),
'route' => null,
'level' => 0,
'dpt_time' => $this->faker->time(),
'arr_time' => $this->faker->time(),
'flight_time' => $this->faker->numberBetween(60, 360),
'load_factor' => $this->faker->randomElement([15, 20, 50, 90, 100]),
'load_factor_variance' => $this->faker->randomElement([15, 20, 50, 90, 100]),
'has_bid' => false,
'active' => true,
'visible' => true,
'days' => 0,
'start_date' => null,
'end_date' => null,
'created_at' => $this->faker->dateTimeBetween('-1 week')->format(
DateTime::ATOM
),
'updated_at' => static fn (array $flight) => $flight['created_at'],
];
}
}
$factory->define(App\Models\Flight::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () {
return factory(\App\Models\Airline::class)->create()->id;
},
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
'route_code' => $faker->randomElement(['', $faker->text(5)]),
'route_leg' => $faker->randomElement(['', $faker->numberBetween(0, 1000)]),
'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;
},
'distance' => $faker->numberBetween(1, 1000),
'route' => null,
'level' => 0,
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->numberBetween(60, 360),
'load_factor' => $faker->randomElement([15, 20, 50, 90, 100]),
'load_factor_variance' => $faker->randomElement([15, 20, 50, 90, 100]),
'has_bid' => false,
'active' => true,
'visible' => true,
'days' => 0,
'start_date' => null,
'end_date' => null,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => static function (array $flight) {
return $flight['created_at'];
},
];
});

View File

@ -1,30 +1,9 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Journal;
class JournalFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Journal::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'currency' => 'USD',
];
}
}
$factory->define(App\Models\Journal::class, function (Faker $faker) {
return [
'currency' => 'USD',
];
});

View File

@ -1,39 +1,20 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Journal;
use App\Models\JournalTransaction;
use Carbon\Carbon;
use Faker\Generator as Faker;
use Ramsey\Uuid\Uuid;
class JournalTransactionsFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = JournalTransaction::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'transaction_group' => Uuid::uuid4()->toString(),
'journal_id' => fn () => Journal::factory()->create()->id,
'credit' => $this->faker->numberBetween(100, 10000),
'debit' => $this->faker->numberBetween(100, 10000),
'currency' => 'USD',
'memo' => $this->faker->sentence(6),
'post_date' => Carbon::now('UTC')->toDateTimeString(),
];
}
}
$factory->define(App\Models\JournalTransaction::class, function (Faker $faker) {
return [
'transaction_group' => Uuid::uuid4()->toString(),
'journal_id' => function () {
return factory(Journal::class)->create()->id;
},
'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD',
'memo' => $faker->sentence(6),
'post_date' => Carbon::now('UTC'),
];
});

View File

@ -1,36 +1,15 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Enums\NavaidType;
use App\Models\Navdata;
use Faker\Generator as Faker;
class NavdataFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Navdata::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => str_replace(' ', '', str_replace('.', '', $this->faker->unique()->text(5))),
'name' => str_replace('.', '', $this->faker->unique()->word),
'type' => $this->faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
'lat' => $this->faker->latitude,
'lon' => $this->faker->longitude,
'freq' => $this->faker->randomFloat(2, 100, 1000),
];
}
}
$factory->define(App\Models\Navdata::class, function (Faker $faker) {
return [
'id' => str_replace(' ', '', str_replace('.', '', $faker->unique()->text(5))),
'name' => str_replace('.', '', $faker->unique()->word),
'type' => $faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'freq' => $faker->randomFloat(2, 100, 1000),
];
});

View File

@ -1,33 +1,14 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\News;
class NewsFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = News::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'user_id' => fn () => \App\Models\User::factory()->create()->id,
'subject' => $this->faker->text(),
'body' => $this->faker->sentence,
];
}
}
$factory->define(App\Models\News::class, function (Faker $faker) {
return [
'id' => null,
'user_id' => function () {
return factory(\App\Models\User::class)->create()->id;
},
'subject' => $faker->text(),
'body' => $faker->sentence,
];
});

View File

@ -1,74 +1,69 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Airline;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Flight;
use App\Models\Pirep;
use Carbon\Carbon;
use Faker\Generator as Faker;
class PirepFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Pirep::class;
/*
* Create a new PIREP
*/
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
$airline = factory(\App\Models\Airline::class)->create();
$flight = factory(\App\Models\Flight::class)->create([
'airline_id' => $airline->id,
]);
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
/** @var Airline $airline */
$airline = Airline::factory()->create();
/** @var Flight $flight */
$flight = Flight::factory()->create(['airline_id' => $airline->id]);
return [
'id' => $this->faker->unique()->numberBetween(10, 10000000),
'airline_id' => fn () => $airline->id,
'user_id' => fn () => \App\Models\User::factory()->create()->id,
'aircraft_id' => fn () => \App\Models\Aircraft::factory()->create()->id,
'flight_id' => fn () => $flight->id,
'flight_number' => fn () => $flight->flight_number,
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => fn () => $flight->dpt_airport_id,
'arr_airport_id' => fn () => $flight->arr_airport_id,
'level' => $this->faker->numberBetween(20, 400),
'distance' => $this->faker->randomFloat(2, 0, 6000),
'planned_distance' => $this->faker->randomFloat(2, 0, 6000),
'flight_time' => $this->faker->numberBetween(60, 360),
'planned_flight_time' => $this->faker->numberBetween(60, 360),
'zfw' => $this->faker->randomFloat(2),
'block_fuel' => $this->faker->randomFloat(2, 0, 1000),
'fuel_used' => fn (array $pirep) => round($pirep['block_fuel'] * .9, 2),
'block_on_time' => Carbon::now('UTC'),
'block_off_time' => fn (array $pirep) => $pirep['block_on_time']->subMinutes(
$pirep['flight_time']
),
'route' => $this->faker->text(200),
'notes' => $this->faker->text(200),
'source' => $this->faker->randomElement(
[PirepSource::MANUAL, PirepSource::ACARS]
),
'source_name' => 'TestFactory',
'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED,
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => fn (array $pirep) => $pirep['created_at'],
];
}
}
return [
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () use ($airline) {
return $airline->id;
},
'user_id' => function () {
return factory(\App\Models\User::class)->create()->id;
},
'aircraft_id' => function () {
return factory(\App\Models\Aircraft::class)->create()->id;
},
'flight_id' => function () use ($flight) {
return $flight->id;
},
'flight_number' => function () use ($flight) {
return $flight->flight_number;
},
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => function () use ($flight) {
return $flight->dpt_airport_id;
},
'arr_airport_id' => function () use ($flight) {
return $flight->arr_airport_id;
},
'level' => $faker->numberBetween(20, 400),
'distance' => $faker->randomFloat(2, 0, 6000),
'planned_distance' => $faker->randomFloat(2, 0, 6000),
'flight_time' => $faker->numberBetween(60, 360),
'planned_flight_time' => $faker->numberBetween(60, 360),
'zfw' => $faker->randomFloat(2),
'block_fuel' => $faker->randomFloat(2, 0, 1000),
'fuel_used' => function (array $pirep) {
return round($pirep['block_fuel'] * .9, 2); // 90% of the fuel loaded was used
},
'block_on_time' => Carbon::now('UTC'),
'block_off_time' => function (array $pirep) {
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
},
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'source_name' => 'TestFactory',
'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED,
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => function (array $pirep) {
return $pirep['created_at'];
},
];
});

View File

@ -1,37 +1,23 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Rank;
class RankFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Rank::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'name' => $this->faker->unique()->text(50),
'hours' => $this->faker->numberBetween(10, 50),
'acars_base_pay_rate' => $this->faker->numberBetween(10, 100),
'manual_base_pay_rate' => $this->faker->numberBetween(10, 100),
'auto_approve_acars' => 0,
'auto_approve_manual' => 0,
'auto_promote' => 0,
];
}
}
/*
* id: 2
name: Junior First Officer
hours: 10
auto_approve_acars: 1
auto_approve_manual: 1
*/
$factory->define(App\Models\Rank::class, function (Faker $faker) {
return [
'id' => null,
'name' => $faker->unique()->text(50),
'hours' => $faker->numberBetween(10, 50),
'acars_base_pay_rate' => $faker->numberBetween(10, 100),
'manual_base_pay_rate' => $faker->numberBetween(10, 100),
'auto_approve_acars' => 0,
'auto_approve_manual' => 0,
'auto_promote' => 0,
];
});

View File

@ -1,34 +1,13 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Role;
class RoleFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Role::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'name' => $this->faker->name,
'display_name' => $this->faker->name,
'read_only' => false,
'disable_activity_checks' => $this->faker->boolean(),
];
}
}
$factory->define(App\Models\Role::class, function (Faker $faker) {
return [
'id' => null,
'name' => $faker->name,
'display_name' => $faker->name,
'read_only' => false,
'disable_activity_checks' => $faker->boolean(),
];
});

View File

@ -1,38 +0,0 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\SimBrief;
use Carbon\Carbon;
class SimBriefFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = SimBrief::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'id' => $this->faker->unique()->numberBetween(10, 10000000),
'user_id' => null,
'flight_id' => null,
'pirep_id' => null,
'acars_xml' => '',
'ofp_xml' => '',
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => fn (array $sb) => $sb['created_at'],
];
}
}

View File

@ -0,0 +1,21 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Carbon\Carbon;
use Faker\Generator as Faker;
$factory->define(App\Models\SimBrief::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 10000000),
'user_id' => null,
'flight_id' => null,
'pirep_id' => null,
'acars_xml' => '',
'ofp_xml' => '',
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => function (array $sb) {
return $sb['created_at'];
},
];
});

View File

@ -1,34 +1,15 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
use Faker\Generator as Faker;
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Subfleet;
class SubfleetFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Subfleet::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'id' => null,
'airline_id' => fn () => \App\Models\Airline::factory()->create()->id,
'name' => $this->faker->unique()->text(50),
'type' => $this->faker->unique()->text(7),
'ground_handling_multiplier' => $this->faker->numberBetween(50, 200),
];
}
}
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
return [
'id' => null,
'airline_id' => function () {
return factory(\App\Models\Airline::class)->create()->id;
},
'name' => $faker->unique()->text(50),
'type' => $faker->unique()->text(7),
'ground_handling_multiplier' => $faker->numberBetween(50, 200),
];
});

View File

@ -1,54 +1,28 @@
<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
namespace App\Database\Factories;
use App\Contracts\Factory;
use App\Models\Airline;
use App\Models\Enums\UserState;
use App\Models\User;
use Faker\Generator as Faker;
use Illuminate\Support\Facades\Hash;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
$factory->define(App\Models\User::class, function (Faker $faker) {
static $password;
/**
* @var string
*/
private static string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
if (empty(self::$password)) {
self::$password = Hash::make('secret');
}
return [
'id' => null,
'pilot_id' => null,
'name' => $this->faker->name,
'email' => $this->faker->safeEmail,
'password' => self::$password,
'api_key' => $this->faker->sha1,
'airline_id' => fn () => Airline::factory()->create()->id,
'rank_id' => 1,
'flights' => $this->faker->numberBetween(0, 1000),
'flight_time' => $this->faker->numberBetween(0, 10000),
'transfer_time' => $this->faker->numberBetween(0, 10000),
'state' => UserState::ACTIVE,
'remember_token' => $this->faker->unique()->text(5),
];
}
}
return [
'id' => null,
'pilot_id' => null,
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'),
'api_key' => $faker->sha1,
'airline_id' => function () {
return factory(Airline::class)->create()->id;
},
'rank_id' => 1,
'flights' => $faker->numberBetween(0, 1000),
'flight_time' => $faker->numberBetween(0, 10000),
'transfer_time' => $faker->numberBetween(0, 10000),
'state' => UserState::ACTIVE,
'remember_token' => $faker->unique()->text(5),
];
});

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use App\Services\Installer\SeederService;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateSettingsTable extends Migration
{
private $seederSvc;
public function __construct()
@ -49,4 +50,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('settings');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Models\Pirep;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
@ -54,4 +55,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('users');
}
};
}

View File

@ -2,9 +2,9 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class RolesPermissionsTables extends Migration
{
public function up()
{
// Create table for storing roles
@ -82,4 +82,4 @@ return new class() extends Migration {
Schema::dropIfExists('role_user');
Schema::dropIfExists('roles');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreatePasswordResetsTable extends Migration
{
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
@ -18,4 +19,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('password_resets');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateSessionsTable extends Migration
{
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
@ -21,4 +22,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('sessions');
}
};
}

View File

@ -3,7 +3,8 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateAirlinesTable extends Migration
{
public function up()
{
Schema::create('airlines', function (Blueprint $table) {
@ -30,4 +31,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('airlines');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Models\Enums\AircraftState;
use App\Models\Enums\AircraftStatus;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateAircraftsTable extends Migration
{
public function up()
{
Schema::create('aircraft', function (Blueprint $table) {
@ -33,4 +34,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('aircraft');
}
};
}

View File

@ -3,7 +3,8 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateFaresTable extends Migration
{
public function up()
{
Schema::create('fares', function (Blueprint $table) {
@ -23,4 +24,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('fares');
}
};
}

View File

@ -3,7 +3,8 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateAirportsTable extends Migration
{
public function up()
{
Schema::create('airports', function (Blueprint $table) {
@ -32,4 +33,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('airports');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Contracts\Model;
use App\Models\Enums\FlightType;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateFlightTables extends Migration
{
public function up()
{
Schema::create('flights', function (Blueprint $table) {
@ -97,4 +98,4 @@ return new class() extends Migration {
Schema::drop('flight_subfleet');
Schema::drop('flights');
}
};
}

View File

@ -3,7 +3,8 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateRanksTable extends Migration
{
public function up()
{
Schema::create('ranks', function (Blueprint $table) {
@ -28,4 +29,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('ranks');
}
};
}

View File

@ -3,7 +3,8 @@
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreateSubfleetTables extends Migration
{
public function up()
{
Schema::create('subfleets', function (Blueprint $table) {
@ -50,4 +51,4 @@ return new class() extends Migration {
Schema::dropIfExists('subfleet_fare');
Schema::dropIfExists('subfleet_rank');
}
};
}

View File

@ -7,7 +7,8 @@ use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use Illuminate\Database\Schema\Blueprint;
return new class() extends Migration {
class CreatePirepTables extends Migration
{
/**
* Run the migrations.
*
@ -105,4 +106,4 @@ return new class() extends Migration {
Schema::dropIfExists('pirep_fields');
Schema::dropIfExists('pirep_field_values');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Contracts\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateBidsTable extends Migration
{
public function up()
{
Schema::create('bids', function (Blueprint $table) {
@ -23,4 +24,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('bids');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateJobsTable extends Migration
{
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
@ -22,4 +23,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('jobs');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateFailedJobsTable extends Migration
{
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
@ -21,4 +22,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('failed_jobs');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateNavdataTables extends Migration
{
public function up()
{
/*
@ -29,4 +30,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('navdata');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Contracts\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateAcarsTables extends Migration
{
public function up()
{
Schema::create('acars', function (Blueprint $table) {
@ -42,4 +43,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('acars');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateStatsTable extends Migration
{
public function up()
{
Schema::create('stats', function (Blueprint $table) {
@ -23,4 +24,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('stats');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateNewsTable extends Migration
{
public function up()
{
Schema::create('news', function (Blueprint $table) {
@ -20,4 +21,4 @@ return new class() extends Migration {
{
Schema::drop('news');
}
};
}

View File

@ -5,7 +5,8 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Modules\Awards\Awards\PilotFlightAwards;
return new class() extends Migration {
class CreateAwardsTable extends Migration
{
public function up()
{
Schema::create('awards', function (Blueprint $table) {
@ -51,4 +52,4 @@ return new class() extends Migration {
Schema::dropIfExists('awards');
Schema::dropIfExists('user_awards');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateExpensesTable extends Migration
{
public function up()
{
Schema::create('expenses', function (Blueprint $table) {
@ -33,4 +34,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('expenses');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateJournalTransactionsTable extends Migration
{
public function up()
{
Schema::create('journal_transactions', function (Blueprint $table) {
@ -32,4 +33,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('journal_transactions');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateJournalsTable extends Migration
{
public function up()
{
Schema::create('journals', function (Blueprint $table) {
@ -22,4 +23,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('journals');
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateLedgersTable extends Migration
{
/**
* Run the migrations.
*
@ -29,4 +30,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('ledgers');
}
};
}

View File

@ -5,7 +5,8 @@ use App\Contracts\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateFilesTable extends Migration
{
/**
* Create the files table. Acts as a morphable
*
@ -39,4 +40,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('files');
}
};
}

View File

@ -5,7 +5,8 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class AddReadonlyToRoles extends Migration
{
public function up(): void
{
Schema::table('roles', static function (Blueprint $table) {
@ -24,4 +25,4 @@ return new class() extends Migration {
$table->dropColumn('read_only');
});
}
};
}

View File

@ -12,7 +12,8 @@ use Illuminate\Support\Facades\Schema;
* 3. Iterate through all of the users and set their `id` to the `pilot_id`
* 4. Change the other tables column types that reference `user_id`
*/
return new class() extends Migration {
class UsersAddPilotId extends Migration
{
public function up()
{
Schema::table('users', static function (Blueprint $table) {
@ -32,4 +33,4 @@ return new class() extends Migration {
$table->dropColumn('pilot_id');
});
}
};
}

View File

@ -4,7 +4,8 @@ use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
class CreateNotificationsTable extends Migration
{
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
@ -21,4 +22,4 @@ return new class() extends Migration {
{
Schema::dropIfExists('notifications');
}
};
}

View File

@ -9,7 +9,8 @@ use Illuminate\Support\Facades\Schema;
/**
* Change the PIREP state column to be a TINYINT
*/
return new class() extends Migration {
class PirepsChangeStateType extends Migration
{
public function up()
{
// Migrate the old rejected state
@ -22,4 +23,4 @@ return new class() extends Migration {
$table->unsignedSmallInteger('state')->change();
});
}
};
}

View File

@ -8,11 +8,12 @@ use Illuminate\Support\Facades\Schema;
/**
* Add a `flight_id` column to the PIREPs table
*/
return new class() extends Migration {
class PirepsAddFlightId extends Migration
{
public function up()
{
Schema::table('pireps', function (Blueprint $table) {
$table->string('flight_id', Model::ID_MAX_LENGTH)->nullable()->after('aircraft_id');
});
}
};
}

View File

@ -7,7 +7,8 @@ use Illuminate\Support\Facades\Schema;
/**
* Add a `flight_type` column to the expenses table
*/
return new class() extends Migration {
class ExpensesAddFlightType extends Migration
{
public function up()
{
Schema::table('expenses', function (Blueprint $table) {
@ -23,4 +24,4 @@ return new class() extends Migration {
$table->dropColumn('flight_type');
});
}
};
}

View File

@ -6,7 +6,8 @@ use Illuminate\Support\Facades\Schema;
/**
* Turn the airport coordinates and other lat/lon coords into decimal type
*/
return new class() extends Migration {
class ModifyAirportsCoordinates extends Migration
{
/**
* Run the migrations.
*
@ -24,4 +25,4 @@ return new class() extends Migration {
$table->decimal('lon', 11, 5)->change()->default(0.0)->nullable();
});
}
};
}

View File

@ -6,11 +6,12 @@ use Illuminate\Support\Facades\Schema;
/**
* Allow the flight field value to be nullable
*/
return new class() extends Migration {
class FlightFieldNullable extends Migration
{
public function up()
{
Schema::table('flight_field_values', function ($table) {
$table->text('value')->change()->nullable();
});
}
};
}

Some files were not shown because too many files have changed in this diff Show More