Merge pull request #440 from nabeelio/dev

Merge 7.0.0-beta.2 to master
This commit is contained in:
Nabeel S
2019-11-19 11:45:13 -05:00
committed by GitHub
713 changed files with 20495 additions and 165110 deletions

26
.editorconfig Normal file
View File

@@ -0,0 +1,26 @@
#
root = true
[*.js]
indent_style = space
indent_size = 2
[*.php]
indent_style = space
indent_size = 4
[*.blade.php]
indent_style = space
indent_size = 2
[*.stub]
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
# Matches the exact files either package.json or .travis.yml
[{package.json, .travis.yml}]
indent_style = space
indent_size = 2

View File

@@ -2,13 +2,16 @@
"extends": "airbnb", "extends": "airbnb",
"env": { "env": {
"es6": true, "es6": true,
"mocha": true "browser": true
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 8 "ecmaVersion": 8
}, },
"rules": { "rules": {
"camelcase": 0, "camelcase": 0,
"no-console": 0,
"func-names": 0,
"prefer-object-spread": 0,
"no-param-reassign": [ "no-param-reassign": [
2, 2,
{ {

30
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**Version**
Please enter the version
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context and attach logs (from `storage/logs/laravel-<date>.log`)

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

10
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
---
daysUntilStale: 60
daysUntilClose: false
exemptLabels:
- pinned
- security
exemptMilestones: true
staleLabel: wontfix
markComment: false
closeComment: false

2
.gitignore vendored
View File

@@ -1,5 +1,7 @@
_ide_helper.php _ide_helper.php
.php_cs.cache
.phpstorm.meta.php .phpstorm.meta.php
.phpunit.result.cache
/vendor /vendor
node_modules/ node_modules/
npm-debug.log npm-debug.log

View File

@@ -4,8 +4,8 @@ Options -Indexes
RewriteEngine On RewriteEngine On
# Handle Authorization Header # Handle Authorization Header
RewriteCond %{HTTP:Authorization} ^(.*) RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny all these files/folders # Deny all these files/folders
RedirectMatch 403 ^/.git/.*?$ RedirectMatch 403 ^/.git/.*?$
@@ -20,6 +20,7 @@ RedirectMatch 403 ^/storage/.*?$
RedirectMatch 403 ^/tests/.*?$ RedirectMatch 403 ^/tests/.*?$
RedirectMatch 403 ^/vendor/.*?$ RedirectMatch 403 ^/vendor/.*?$
RedirectMatch 403 ^/.bowerrc$ RedirectMatch 403 ^/.bowerrc$
RedirectMatch 403 ^/.env
RedirectMatch 403 ^/artisan$ RedirectMatch 403 ^/artisan$
RedirectMatch 403 ^/composer.json RedirectMatch 403 ^/composer.json
RedirectMatch 403 ^/composer.lock RedirectMatch 403 ^/composer.lock
@@ -32,12 +33,6 @@ RedirectMatch 403 ^/package.json
RedirectMatch 403 ^/package-lock.json RedirectMatch 403 ^/package-lock.json
RedirectMatch 403 ^/phpunit.xml RedirectMatch 403 ^/phpunit.xml
RedirectMatch 403 ^/webpack.mix.js RedirectMatch 403 ^/webpack.mix.js
RedirectMatch 403 ^/yarn.lock
# Redirect Trailing Slashes If Not A Folder... RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

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

@@ -23,9 +23,8 @@ disabled:
# - unalign_equals # - unalign_equals
finder: finder:
exclude: exclude:
- modules - node_modules
- node_modules - storage
- storage - vendor
- vendor
name: "*.php" name: "*.php"
not-name: "*.blade.php" not-name: "*.blade.php"

View File

@@ -1,11 +1,22 @@
#
# Travis CI config file
#
language: php language: php
php: php:
#- '7.0' - '7.2'
- '7.1' - '7.3'
- '7.2'
#- nightly matrix:
include:
- php: '7.2'
- php: '7.3'
fast_finish: true
cache: cache:
# Cache lives for 10 min
# Default of 3m might not be long enough for all the runs
timeout: 600
directories: directories:
- "$HOME/.composer/cache" - "$HOME/.composer/cache"
- "$HOME/.npm" - "$HOME/.npm"
@@ -13,45 +24,58 @@ cache:
services: services:
- mysql - mysql
before_script: install:
- cp .travis/env.travis.php env.php
- composer install --dev --no-interaction --verbose - composer install --dev --no-interaction --verbose
- cp .travis/env.travis.php env.php
- cp .travis/phpunit.travis.xml phpunit.xml
before_script:
- php artisan database:create --reset
- php artisan migrate:refresh --seed
script: script:
- php artisan database:create --reset - vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no
- php artisan migrate:refresh --seed - vendor/bin/phpunit --debug --verbose
- cp .travis/phpunit.travis.xml phpunit.xml
- vendor/bin/phpunit --debug --verbose
after_failure: after_failure:
- cat storage/logs/*.log - cat storage/logs/*.log
jobs: jobs:
include: include:
# Just packages up a release
- stage: package - stage: package
script: skip script: skip
before_deploy: before_deploy:
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash - curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
# Configure the conditional deployment
# https://docs.travis-ci.com/user/deployment/#examples-of-conditional-deployment
deploy: deploy:
- provider: script - provider: script
skip_cleanup: true skip_cleanup: true
script: ./.travis/deploy_script.sh script: ./.travis/deploy_script.sh
on: on:
all_branches: true all_branches: true
php: '7.1' repo: nabeelio/phpvms
php: '7.2'
tags: false
# RELEASE STAGE
# Only runs when there's a tag applied to this release (tag should be the version)
# This uses Github Releases and posts it there (provider: releases)
# https://docs.travis-ci.com/user/deployment/releases
- stage: release - stage: release
script: skip script: skip
before_deploy: before_deploy:
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash - curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
- ./.travis/deploy_script.sh - ./.travis/deploy_script.sh
deploy: deploy:
provider: releases provider: releases
skip_cleanup: true skip_cleanup: true
api_key: api_key: $GITHUB_TOKEN
secure: kAOYEThsSF8wM7vx+e+xWKhlvsNzhgKn1bk0zLBb7RLUM5pHIGKV/j0KrCNspwIUEPF0O594H6hCyswlpIZfxW2mTnmPqfbKxG/H2rLEAoOV0/MqzeC/gffxm7Eop6Sn4T/UC9kLSgqRynllbYtJDK6aWESdnvK3Fka0Cnpn7l/2phEf2J/nOF6QT/utpws1E0MUGqrKvX1/UYIu8np5e5aYLPOXnqahK8qzJFL4CyNBv+fhXuXfmOF4UbNbSPnrg/kY0QpUtFpz9ebvg5BjfMXJT0P4Q1BjgKBN76A7vz+ZfPmW6SqKv3o1yisXAgBWzylXh8B6pK+cUk4uXbagcGcIdkGOI6pQ5sLq+JOkBhVjSfogERePkt44KPif4EMsLRw/Jp4pTMy/vmgrON/jkbA+jXsOARTG5vAwIq4lyZzZXWUfirYwXeCfasgf+xTdo9C0cOE0jlqojO7SdF2CinDk9BduYpBTectea8Xx+YP5R1JCZNORDYynlLHKMW/8PJyAG+AsbcfKNTobQAfxw1nHa7GoKP1j4MSx1UtbulZdhmeRX/nUTFIvfgEDrl4cdBlt0/o5SuyN92DiCnvJZaYHcgXwYMvoqdXxBCnBKsM/1BZcykWi7Zt/q8krWYCOfCzBN4TDdmrKsEOUkCSOL9mI6gERHGmcGZN05PxU950=
file_glob: true file_glob: true
file: build/* file: build/*
on: on:
tags: true tags: true
repo: nabeelio/phpvms repo: nabeelio/phpvms
php: '7.1' php: '7.2'

View File

@@ -14,7 +14,7 @@ if [ "$TRAVIS" = "true" ]; then
exit 0; exit 0;
fi; fi;
BASE_VERSION=`php artisan phpvms:version --base-only` BASE_VERSION=$(php artisan phpvms:version --base-only)
PKG_NAME=${BASE_VERSION}-${TRAVIS_BRANCH} PKG_NAME=${BASE_VERSION}-${TRAVIS_BRANCH}
fi fi
@@ -23,7 +23,7 @@ if [ "$TRAVIS" = "true" ]; then
echo "Writing $TAR_NAME" echo "Writing $TAR_NAME"
php artisan phpvms:version --write > VERSION php artisan phpvms:version --write > VERSION
VERSION=`cat VERSION` VERSION=$(cat VERSION)
echo "Version: $VERSION" echo "Version: $VERSION"
echo "Cleaning files" echo "Cleaning files"
@@ -51,19 +51,28 @@ if [ "$TRAVIS" = "true" ]; then
# Leftover individual files to delete # Leftover individual files to delete
declare -a remove_files=( declare -a remove_files=(
.git .git
.github
.sass-cache .sass-cache
.idea .idea
.travis .travis
docker
tests tests
_ide_helper.php _ide_helper.php
.dpl .dpl
.editorconfig
.eslintignore .eslintignore
.eslintrc .eslintrc
.php_cs
.php_cs.cache
.phpstorm.meta.php .phpstorm.meta.php
.styleci.yml .styleci.yml
.phpunit.result.cache
env.php env.php
intellij_style.xml
config.php config.php
docker-compose.yml
Makefile Makefile
phpcs.xml
phpunit.xml phpunit.xml
phpvms.iml phpvms.iml
Procfile Procfile
@@ -82,13 +91,25 @@ if [ "$TRAVIS" = "true" ]; then
find . -type d -name "sass-cache" -print0 | xargs rm -rf find . -type d -name "sass-cache" -print0 | xargs rm -rf
# clear any app specific stuff that might have been loaded in # clear any app specific stuff that might have been loaded in
find storage/app -mindepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf {} + find storage/app -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf {} +
find storage/app/public -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} + find storage/app/public -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name avatars -not -name uploads -print0 -exec rm -rf {} +
find storage/app/public/avatars -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/app/public/uploads -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/debugbar -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/docker -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/framework/cache -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} + find storage/framework/cache -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/framework/sessions -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} + find storage/framework/sessions -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/framework/views -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} + find storage/framework/views -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/logs -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} + find storage/logs -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
mkdir -p storage/app/public/avatars
mkdir -p storage/app/public/uploads
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
mkdir -p storage/framework/views
# Regenerate the autoloader and classes
composer dump-autoload
make clean make clean
echo "Creating Tarball" echo "Creating Tarball"

View File

@@ -1,14 +0,0 @@
APP_ENV=prod
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=phpvms
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=array

View File

@@ -2,29 +2,28 @@
exit(); exit();
?> ?>
APP_ENV=dev APP_ENV="dev"
APP_KEY=base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY= APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
APP_URL=http://localhost APP_URL="http://localhost"
APP_SKIN=default APP_SKIN="default"
APP_DEBUG=true APP_DEBUG="true"
APP_LOCALE=en APP_LOCALE="en"
PHPVMS_INSTALLED=true PHPVMS_INSTALLED="true"
VACENTRAL_API_KEY=
APP_LOG=daily APP_LOG="daily"
APP_LOG_LEVEL=debug APP_LOG_LEVEL="debug"
APP_LOG_MAX_FILES=3 APP_LOG_MAX_FILES="3"
DB_CONNECTION=mysql DB_CONNECTION="mysql"
DB_HOST=127.0.0.1 DB_HOST="127.0.0.1"
DB_PORT=3306 DB_PORT="3306"
DB_DATABASE=phpvms DB_DATABASE="phpvms"
DB_USERNAME=root DB_USERNAME="root"
DB_PASSWORD= DB_PASSWORD=
CACHE_DRIVER=file CACHE_DRIVER="file"
CACHE_PREFIX= CACHE_PREFIX=
SESSION_DRIVER=file SESSION_DRIVER="file"
QUEUE_DRIVER=database QUEUE_DRIVER="database"

View File

@@ -13,6 +13,9 @@
<directory suffix="Test.php">./tests</directory> <directory suffix="Test.php">./tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<extensions>
<extension class="Tests\Bootstrap"/>
</extensions>
<filter> <filter>
<whitelist processUncoveredFilesFromWhitelist="true"> <whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
@@ -25,5 +28,18 @@
<ini name="error_reporting" value="E_ALL"/> <ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="On"/> <ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/> <ini name="display_startup_errors" value="On"/>
<server name="APP_ENV" value="testing"/>
<server name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
<server name="APP_DEBUG" value="true"/>
<server name="APP_LOG_LEVEL" value="debug"/>
<server name="DB_CONNECTION" value="memory"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="QUEUE_DRIVER" value="sync"/>
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
</php> </php>
</phpunit> </phpunit>

View File

@@ -1,72 +1,9 @@
## Alpha 3 ## Beta 2 (7.0.0-beta.2)
!! Please do a complete reinstall, with a new database - Switching to semver
- PHP 7.2 minimum
- Lots of fixes, view the [Github Milestone](https://github.com/nabeelio/phpvms/milestone/2?closed=1) for details
- Finances! The finance portions have been implemented, you can [read about them here](http://docs.phpvms.net/concepts/finances) ## Beta 1 (v7.0.0-beta)
- Awards! Added the award plugin system. [see docs](http://docs.phpvms.net/customizing/awards)
- Import/Export in admin panel for aircraft, airports, expenses, fares, flights and subfleets
- Changed theme system to using [laravel-theme](https://github.com/igaster/laravel-theme), there are changes to making theming much simpler with much more flexibility.
- Added cron task for background tasks
- Expanded on flight types to match IATA SIMM format
- Added subfleet `cost_block_hour`
- Fixed several security vulnerabilities (thanks magicflyer!)
- Fuel units changed to lbs/kgs [#193](https://github.com/nabeelio/phpvms/issues/193)
- Airports can be restricted to only hubs on registration/user profile
- Cleaned up a lot unused icons and files [#195](https://github.com/nabeelio/phpvms/issues/195)
- Rank restrictions for PIREPs are respected [#170](https://github.com/nabeelio/phpvms/issues/170)
- API: Added the ability to get/update/delete user bids [#172](https://github.com/nabeelio/phpvms/issues/172)
- API: Added `block_time` parameter for PIREP prefile/update/file calls
- API: Added `block_on_time` and `block_off_time` for PIREP prefile/update/file calls
- Artisan: Added a `phpvms:csv-import [table] [file]` to import from CSV
- Artisan: Added a `phpvms:yaml-export [tables]` to export tables to YAML files which can be re-imported using `phpvms:yaml-import`
- Numerous bug fixes
## Alpha 2 (2018-02-23, v7.0.0-alpha2)
!! Please do a full reinstall, with recreating the database
- Bump minimum PHP version to 7.1, since 7.0 is already deprecated - [#166](https://github.com/nabeelio/phpvms/issues/166)
- Upgraded to Laravel 5.6
- Installer: Updated to create `config.php` file, to override config file values without having to modify the config files themselves
- Installer: Moved most options into the `config.php`, out of the `env.php` file
- Admin: Set the country for the airline [#191](https://github.com/nabeelio/phpvms/issues/191)
- Admin: Add ranks from the subfleet edit page
- Admin: Added flight time field to flight add/edit page
- Admin: PIREP hours can't be changed after it's no longer in a pending state
- Admin: Removed the tail number field
- DB: `airport.tz` to `airport.timezone`
- DB: Removed `aircaft.tail_number`
- DB: Decimal type field sizes shrunk to the default sizes
- DB: Removed the `raw_data` field from the PIREPs table
- API: All units expected in imperial (distance in nautical miles, fuel in lbs, mass in lbs)
- API: Added ability to add/remove bids for users
- API: Added a setting to only show aircraft that are at the departure airport of a flight [#171](https://github.com/nabeelio/phpvms/issues/171)
- API: Most calls, with exception of ACARS, are now private and require an API key to access [#173](https://github.com/nabeelio/phpvms/issues/173)
- API: Create an `/api/flight/:id/route` call to return the route information for a flight [#183](https://github.com/nabeelio/phpvms/issues/183)
- API: Allow a `fields` object to set custom PIREP fields, also returns the current values
- API: `level` not required in prefile anymore
- Setting: Restrict to aircraft that are at a flight's departure airport [#171](https://github.com/nabeelio/phpvms/issues/171)
- Setting: Implementation of filtering flights that are only at the user's current airport [#174](https://github.com/nabeelio/phpvms/issues/174)
- Templates: Add a `SKIN_NAME` template variable to reference the current skin, vs hardcoding the skin name in the templates
- Console: Added `php artisan phpvms:dev-install` command which creates the config files and creates the database/inserts sample data in one command [#176](https://github.com/nabeelio/phpvms/issues/176)
- Rank aircraft restrictions are properly working now [#170](https://github.com/nabeelio/phpvms/issues/170)
#### Fixes
- PIREP fields being set when filing manually is working
- ACARS data wasn't being ordered properly, causing issues on the map [77055991](https://github.com/nabeelio/phpvms/commit/77055991af36877552e1921466987d3066774d6b)
- Field for the rank's image changed to string input [b5dbde8](https://github.com/nabeelio/phpvms/commit/b5dbde84c4c786799f474117381b8227642f0777)
- Set a default value for a setting [#106](https://github.com/nabeelio/phpvms/issues/106)
- Admin: Rank image field fixed
- API: Only active airlines are returned
- API; Return errors if user isn't allowed on the submitted aircraft [#170](https://github.com/nabeelio/phpvms/issues/170)
- API: Fixed typo from `subfleet` to `subfleets` in the `/api/flights` call(s) [f6b2102](https://github.com/nabeelio/phpvms/commit/f6b2102e4827da6177eb4eee0c3ce0d38eb78ce3)
- API: Wrapped all calls in a `data` field
- API: `planned_distance` and `planned_flight_time` fields are now optional
- Setting: Subfleets returned in the flight calls respect the `pireps.restrict_aircraft_to_rank` setting [#170](https://github.com/nabeelio/phpvms/issues/170)
------
## Alpha 1 (2018-02-04, v7.0.0-alpha1)
- Initial Release - Initial Release

View File

@@ -29,6 +29,13 @@ clean:
clean-routes: clean-routes:
@php artisan route:clear @php artisan route:clear
.PHONY: clear
clear:
@php artisan cache:clear
@php artisan config:clear
@php artisan route:clear
@php artisan view:clear
.PHONY: build .PHONY: build
build: build:
@php $(COMPOSER) install --no-interaction @php $(COMPOSER) install --no-interaction
@@ -36,7 +43,7 @@ build:
# This is to build all the stylesheets, etc # This is to build all the stylesheets, etc
.PHONY: build-assets .PHONY: build-assets
build-assets: build-assets:
yarn run dev yarn run production
.PHONY: install .PHONY: install
install: build install: build
@@ -52,13 +59,16 @@ update: build
@echo "Done!" @echo "Done!"
.PHONY: reset .PHONY: reset
reset: cleanapp/Models/Traits/JournalTrait.php reset: clean
@php $(COMPOSER) dump-autoload @php $(COMPOSER) dump-autoload
@make reload-db @make reload-db
.PHONY: reload-db .PHONY: reload-db
reload-db: reload-db:
@php artisan phpvms:dev-install --reset-db @php artisan database:create --reset
@php artisan migrate --seed
@echo "Done!"
@make clean
.PHONY: tests .PHONY: tests
tests: test tests: test
@@ -68,9 +78,13 @@ test:
#php artisan database:create --reset #php artisan database:create --reset
vendor/bin/phpunit --debug --verbose vendor/bin/phpunit --debug --verbose
.PHONY: .PHONY: phpcs
phpstan: phpcs:
vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app @vendor/bin/php-cs-fixer fix --config=.php_cs -v --diff --dry-run
#.PHONY: phpstan
#phpstan:
# vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app
.PHONY: replay-acars .PHONY: replay-acars
replay-acars: replay-acars:

View File

@@ -1,5 +1,5 @@
dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground #dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground
php-fpm: /usr/local/sbin/php-fpm --nodaemonize php-fpm: /usr/local/sbin/php-fpm --nodaemonize
nginx: /usr/local/bin/nginx -g 'daemon off;' nginx: /usr/local/bin/nginx -g 'daemon off;'
#mysql: /usr/local/bin/mysqld mysql: docker-compose --file ~/docker/mysql/docker-compose.yml up
#mailhog: /usr/local/bin/mailhog #mailhog: /usr/local/bin/mailhog

View File

@@ -2,16 +2,15 @@
[![Build Status](https://travis-ci.org/nabeelio/phpvms.svg)](https://travis-ci.org/nabeelio/phpvms) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d668bebb0a3c46bda381af16ce3d9450)](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nabeelio/phpvms&amp;utm_campaign=Badge_Grade) [![Latest Stable Version](https://poser.pugx.org/nabeel/phpvms/v/stable)](https://packagist.org/packages/nabeel/phpvms) ![StyleCI](https://github.styleci.io/repos/93688482/shield?branch=dev) [![License](https://poser.pugx.org/nabeel/phpvms/license)](https://packagist.org/packages/nabeel/phpvms) [![Build Status](https://travis-ci.org/nabeelio/phpvms.svg)](https://travis-ci.org/nabeelio/phpvms) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d668bebb0a3c46bda381af16ce3d9450)](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nabeelio/phpvms&amp;utm_campaign=Badge_Grade) [![Latest Stable Version](https://poser.pugx.org/nabeel/phpvms/v/stable)](https://packagist.org/packages/nabeel/phpvms) ![StyleCI](https://github.styleci.io/repos/93688482/shield?branch=dev) [![License](https://poser.pugx.org/nabeel/phpvms/license)](https://packagist.org/packages/nabeel/phpvms)
The next phpvms version built on the laravel framework. work in progress. If you're looking for The next phpvms version built on the laravel framework. work in progress. The latest documentation, with installation instructions is available
the old, phpVMS classic, it's [available here](https://github.com/nabeelio/phpvms_v2). [on the phpVMS documentation](http://docs.phpvms.net/) page.
# installation # installation
A full distribution, with all of the composer dependencies, is available at this A full distribution, with all of the composer dependencies, is available at this
[GitHub Releases](https://github.com/nabeelio/phpvms/releases) link. [GitHub Releases](https://github.com/nabeelio/phpvms/releases) link.
The latest documentation, with installation instructions is available
[on the phpVMS documentation](http://docs.phpvms.net/) page.
## Requirements ## Requirements
@@ -30,6 +29,33 @@ The latest documentation, with installation instructions is available
## Installer ## Installer
1. Upload to your server 1. Upload to your server
2. Visit the site, and follow the link to the installer 1. Visit the site, and follow the link to the installer
[View installation details](http://docs.phpvms.net/setup/installation) [View installation details](http://docs.phpvms.net/setup/installation)
# development environment
A full development environment can be brought up using Docker:
```bash
composer install
yarn install
docker-compose build
docker-compose 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:
```
127.0.0.1 phpvms.test
```
## Building JS/CSS assets
Yarn is required, run:
```bash
make build-assets
```
This will build all of the assets according to the webpack file.

View File

@@ -2,7 +2,7 @@
namespace App\Awards; namespace App\Awards;
use App\Interfaces\Award; use App\Contracts\Award;
/** /**
* Simple example of an awards class, where you can apply an award when a user * Simple example of an awards class, where you can apply an award when a user

View File

@@ -2,14 +2,11 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Facades\Utils; use App\Facades\Utils;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
/**
* Class AcarsReplay
*/
class AcarsReplay extends Command class AcarsReplay extends Command
{ {
protected $signature = 'phpvms:replay {files} {--manual} {--write-all} {--no-submit}'; protected $signature = 'phpvms:replay {files} {--manual} {--write-all} {--no-submit}';
@@ -172,7 +169,7 @@ class AcarsReplay extends Command
* @var $flights Collection * @var $flights Collection
*/ */
$flights = collect($files)->transform(function ($f) { $flights = collect($files)->transform(function ($f) {
$file = storage_path('/replay/'.$f.'.json'); $file = $f;
if (file_exists($file)) { if (file_exists($file)) {
$this->info('Loading '.$file); $this->info('Loading '.$file);
$contents = file_get_contents($file); $contents = file_get_contents($file);

View File

@@ -2,12 +2,9 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use Artisan; use Illuminate\Support\Facades\Artisan;
/**
* Class ComposerCommand
*/
class ComposerCommand extends Command class ComposerCommand extends Command
{ {
protected $signature = 'phpvms:composer {cmd}'; protected $signature = 'phpvms:composer {cmd}';

View File

@@ -2,12 +2,10 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use Log; use Illuminate\Support\Facades\Log;
use Tivie\OS\Detector;
/**
* Class CreateDatabase
*/
class CreateDatabase extends Command class CreateDatabase extends Command
{ {
protected $signature = 'database:create {--reset} {--conn=?}'; protected $signature = 'database:create {--reset} {--conn=?}';
@@ -20,7 +18,7 @@ class CreateDatabase extends Command
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->os = new \Tivie\OS\Detector(); $this->os = new Detector();
} }
/** /**

View File

@@ -2,20 +2,23 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Models\Acars; use App\Models\Acars;
use App\Models\Airline; use App\Models\Airline;
use App\Models\Pirep; use App\Models\Pirep;
use App\Models\User; use App\Models\User;
use App\Repositories\AcarsRepository;
use App\Services\AirportService;
use App\Services\AwardService; use App\Services\AwardService;
use App\Services\DatabaseService; use App\Services\DatabaseService;
use DB; use App\Services\UserService;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PDO; use PDO;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
/**
* Class DevCommands
*/
class DevCommands extends Command class DevCommands extends Command
{ {
protected $signature = 'phpvms {cmd} {param?}'; protected $signature = 'phpvms {cmd} {param?}';
@@ -30,6 +33,7 @@ class DevCommands extends Command
public function __construct(DatabaseService $dbSvc) public function __construct(DatabaseService $dbSvc)
{ {
parent::__construct(); parent::__construct();
$this->dbSvc = $dbSvc; $this->dbSvc = $dbSvc;
} }
@@ -46,13 +50,17 @@ class DevCommands extends Command
} }
$commands = [ $commands = [
'list-awards' => 'listAwardClasses', 'clear-acars' => 'clearAcars',
'clear-acars' => 'clearAcars', 'clear-users' => 'clearUsers',
'clear-users' => 'clearUsers', 'compile-assets' => 'compileAssets',
'compile-assets' => 'compileAssets', 'db-attrs' => 'dbAttrs',
'db-attrs' => 'dbAttrs', 'list-awards' => 'listAwardClasses',
'manual-insert' => 'manualInsert', 'live-flights' => 'liveFlights',
'xml-to-yaml' => 'xmlToYaml', 'manual-insert' => 'manualInsert',
'metar' => 'getMetar',
'recalculate-stats' => 'recalculateStats',
'reset-install' => 'resetInstall',
'xml-to-yaml' => 'xmlToYaml',
]; ];
if (!array_key_exists($command, $commands)) { if (!array_key_exists($command, $commands)) {
@@ -183,6 +191,19 @@ class DevCommands extends Command
$this->info('Writing yaml to storage: '.$file_name); $this->info('Writing yaml to storage: '.$file_name);
} }
protected function getMetar(): void
{
$icao = $this->argument('param');
if (!$icao) {
$this->error('Enter an ICAO!');
exit();
}
$airportSvc = app(AirportService::class);
$metar = $airportSvc->getMetar($icao);
$this->info($metar->raw);
}
/** /**
* Insert the rows from the file, manually advancing each row * Insert the rows from the file, manually advancing each row
*/ */
@@ -212,4 +233,68 @@ class DevCommands extends Command
} }
} }
} }
/**
* Recalculate the stats for all users
*/
protected function recalculateStats(): void
{
$userSvc = app(UserService::class);
$userSvc->recalculateAllUserStats();
}
/**
* Delete all of the tables, etc from the database, for a clean install
*/
protected function resetInstall(): void
{
$confirm = $this->ask('This will erase your entire install and database, are you sure? y/n ');
if (strtolower($confirm) !== 'y') {
exit(0);
}
try {
if (config('database.default') === 'mysql') {
DB::statement('SET foreign_key_checks=0');
}
$this->info('Dropping all tables');
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
foreach ($tables as $table) {
Schema::dropIfExists($table);
}
} catch (QueryException $e) {
$this->error('DB error: '.$e->getMessage());
}
$this->info('Deleting config file');
try {
unlink('config.php');
} catch (\Exception $e) {
}
$this->info('Deleting env file');
try {
unlink('env.php');
} catch (\Exception $e) {
}
$this->info('Clearing caches');
Artisan::call('cache:clear');
Artisan::call('route:clear');
Artisan::call('config:clear');
Artisan::call('view:clear');
$this->info('Done!');
}
public function liveFlights(): void
{
$acarsRepo = app(AcarsRepository::class);
$flights = $acarsRepo->getPositions(setting('acars.live_time'))->toArray();
dd($flights);
}
} }

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use Modules\Installer\Services\ConfigService; use Modules\Installer\Services\ConfigService;
/** /**
@@ -13,13 +13,14 @@ class DevInstall extends Command
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}'; protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
protected $description = 'Run a developer install and run the sample migration'; protected $description = 'Run a developer install and run the sample migration';
/** private $databaseSeeder;
* The YAML files with sample data to import
*/ public function __construct(\DatabaseSeeder $databaseSeeder)
protected $yaml_imports = [ {
'sample.yml', parent::__construct();
'acars.yml',
]; $this->databaseSeeder = $databaseSeeder;
}
/** /**
* Run dev related commands * Run dev related commands
@@ -45,16 +46,6 @@ class DevInstall extends Command
'--seed' => true, '--seed' => true,
]); ]);
//
//
$this->info('Importing sample data');
foreach ($this->yaml_imports as $yml) {
$this->call('phpvms:yaml-import', [
'files' => ['app/Database/seeds/'.$yml],
]);
}
$this->info('Done!'); $this->info('Done!');
} }

View File

@@ -2,12 +2,9 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Services\ImportService; use App\Services\ImportService;
/**
* Class ImportCsv
*/
class ImportCsv extends Command class ImportCsv extends Command
{ {
protected $signature = 'phpvms:csv-import {type} {file}'; protected $signature = 'phpvms:csv-import {type} {file}';
@@ -23,6 +20,7 @@ class ImportCsv extends Command
public function __construct(ImportService $importer) public function __construct(ImportService $importer)
{ {
parent::__construct(); parent::__construct();
$this->importer = $importer; $this->importer = $importer;
} }
@@ -36,11 +34,11 @@ class ImportCsv extends Command
$type = $this->argument('type'); $type = $this->argument('type');
$file = $this->argument('file'); $file = $this->argument('file');
if (\in_array($type, ['flight', 'flights'])) { if (\in_array($type, ['flight', 'flights'], true)) {
$status = $this->importer->importFlights($file); $status = $this->importer->importFlights($file);
} elseif ($type === 'aircraft') { } elseif ($type === 'aircraft') {
$status = $this->importer->importAircraft($file); $status = $this->importer->importAircraft($file);
} elseif (\in_array($type, ['airport', 'airports'])) { } elseif (\in_array($type, ['airport', 'airports'], true)) {
$status = $this->importer->importAirports($file); $status = $this->importer->importAirports($file);
} elseif ($type === 'subfleet') { } elseif ($type === 'subfleet') {
$status = $this->importer->importSubfleets($file); $status = $this->importer->importSubfleets($file);

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
class ImportFromClassic extends Command class ImportFromClassic extends Command
{ {

View File

@@ -2,13 +2,10 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Models\Enums\NavaidType; use App\Models\Enums\NavaidType;
use App\Models\Navdata; use App\Models\Navdata;
/**
* Class NavdataImport
*/
class NavdataImport extends Command class NavdataImport extends Command
{ {
protected $signature = 'phpvms:navdata'; protected $signature = 'phpvms:navdata';

View File

@@ -2,12 +2,9 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use GuzzleHttp\Client; use GuzzleHttp\Client;
/**
* Class TestApi
*/
class TestApi extends Command class TestApi extends Command
{ {
protected $signature = 'phpvms:test-api {apikey} {url}'; protected $signature = 'phpvms:test-api {apikey} {url}';

View File

@@ -2,33 +2,21 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Services\VersionService;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
/**
* Class Version
*/
class Version extends Command class Version extends Command
{ {
protected $signature = 'phpvms:version {--write} {--base-only}'; protected $signature = 'phpvms:version {--write} {--base-only}';
/** private $versionSvc;
* Create the version number that gets written out
* public function __construct(VersionService $versionSvc)
* @param mixed $cfg
*
* @return bool|string
*/
protected function createVersionNumber($cfg)
{ {
exec($cfg['git']['git-local'], $version); parent::__construct();
$version = substr($version[0], 0, $cfg['build']['length']);
// prefix with the date in YYMMDD format $this->versionSvc = $versionSvc;
$date = date('ymd');
$version = $date.'-'.$version;
return $version;
} }
/** /**
@@ -38,27 +26,17 @@ class Version extends Command
*/ */
public function handle() public function handle()
{ {
$version_file = config_path('version.yml'); // Write the updated build number out to the file
$cfg = Yaml::parse(file_get_contents($version_file));
// Get the current build id
$build_number = $this->createVersionNumber($cfg);
$cfg['build']['number'] = $build_number;
$c = $cfg['current'];
$version = "v{$c['major']}.{$c['minor']}.{$c['patch']}-{$build_number}";
if ($this->option('write')) { if ($this->option('write')) {
$version_file = config_path('version.yml');
$cfg = Yaml::parse(file_get_contents($version_file));
$build_number = $this->versionSvc->getBuildId($cfg);
$cfg['build']['number'] = $build_number;
file_put_contents($version_file, Yaml::dump($cfg, 4, 2)); file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
} }
// Only show the major.minor.patch version $version = $this->versionSvc->getCurrentVersion(!$this->option('base-only'));
if ($this->option('base-only')) {
$version = 'v'.$cfg['current']['major'].'.'
.$cfg['current']['minor'].'.'
.$cfg['current']['patch'];
}
echo $version."\n"; echo $version."\n";
} }
} }

View File

@@ -2,8 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Services\DatabaseService;
use DB; use DB;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
@@ -15,16 +14,6 @@ class YamlExport extends Command
protected $signature = 'phpvms:yaml-export {tables*}'; protected $signature = 'phpvms:yaml-export {tables*}';
protected $description = 'YAML table export'; protected $description = 'YAML table export';
/**
* YamlExport constructor.
*
* @param DatabaseService $dbSvc
*/
public function __construct(DatabaseService $dbSvc)
{
parent::__construct();
}
/** /**
* Run dev related commands * Run dev related commands
*/ */

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Console\Command; use App\Contracts\Command;
use App\Services\DatabaseService; use App\Services\DatabaseService;
/** /**
@@ -22,6 +22,7 @@ class YamlImport extends Command
public function __construct(DatabaseService $dbSvc) public function __construct(DatabaseService $dbSvc)
{ {
parent::__construct(); parent::__construct();
$this->dbSvc = $dbSvc; $this->dbSvc = $dbSvc;
} }

View File

@@ -2,7 +2,7 @@
namespace App\Console\Cron; namespace App\Console\Cron;
use App\Console\Command; use App\Contracts\Command;
use App\Events\CronHourly; use App\Events\CronHourly;
/** /**
@@ -17,7 +17,7 @@ class Hourly extends Command
public function handle(): void public function handle(): void
{ {
$this->redirectLoggingToStdout('cron'); $this->redirectLoggingToFile('cron');
event(new CronHourly()); event(new CronHourly());
} }
} }

View File

@@ -2,7 +2,7 @@
namespace App\Console\Cron; namespace App\Console\Cron;
use App\Console\Command; use App\Contracts\Command;
use App\Events\CronMonthly; use App\Events\CronMonthly;
/** /**
@@ -19,7 +19,7 @@ class Monthly extends Command
public function handle(): void public function handle(): void
{ {
$this->redirectLoggingToStdout('cron'); $this->redirectLoggingToFile('cron');
event(new CronMonthly()); event(new CronMonthly());
} }
} }

View File

@@ -2,7 +2,7 @@
namespace App\Console\Cron; namespace App\Console\Cron;
use App\Console\Command; use App\Contracts\Command;
use App\Events\CronNightly; use App\Events\CronNightly;
/** /**
@@ -19,7 +19,7 @@ class Nightly extends Command
public function handle(): void public function handle(): void
{ {
$this->redirectLoggingToStdout('cron'); $this->redirectLoggingToFile('cron');
event(new CronNightly()); event(new CronNightly());
} }
} }

View File

@@ -2,7 +2,7 @@
namespace App\Console\Cron; namespace App\Console\Cron;
use App\Console\Command; use App\Contracts\Command;
use App\Events\CronWeekly; use App\Events\CronWeekly;
/** /**
@@ -19,7 +19,7 @@ class Weekly extends Command
public function handle(): void public function handle(): void
{ {
$this->redirectLoggingToStdout('cron'); $this->redirectLoggingToFile('cron');
event(new CronWeekly()); event(new CronWeekly());
} }
} }

View File

@@ -6,12 +6,10 @@ use App\Console\Cron\Hourly;
use App\Console\Cron\Monthly; use App\Console\Cron\Monthly;
use App\Console\Cron\Nightly; use App\Console\Cron\Nightly;
use App\Console\Cron\Weekly; use App\Console\Cron\Weekly;
use App\Services\CronService;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
/**
* Class Kernel
*/
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/** /**
@@ -27,6 +25,14 @@ class Kernel extends ConsoleKernel
$schedule->command(Weekly::class)->weeklyOn(0); $schedule->command(Weekly::class)->weeklyOn(0);
$schedule->command(Monthly::class)->monthlyOn(1); $schedule->command(Monthly::class)->monthlyOn(1);
$schedule->command(Hourly::class)->hourly(); $schedule->command(Hourly::class)->hourly();
// When spatie-backups runs
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
// Update the last time the cron was run
$cronSvc = app(CronService::class);
$cronSvc->updateLastRunTime();
} }
/** /**
@@ -36,7 +42,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands(): void protected function commands(): void
{ {
require app_path('Routes/console.php'); require app_path('Http/Routes/console.php');
$this->load(__DIR__.'/Commands'); $this->load(__DIR__.'/Commands');
$this->load(__DIR__.'/Cron'); $this->load(__DIR__.'/Cron');
} }

View File

@@ -75,7 +75,7 @@ class Importer
'name' => '', 'name' => '',
'user' => '', 'user' => '',
'pass' => '', 'pass' => '',
'table_prefix' => 'phpvms_', 'table_prefix' => '',
], $db_creds); ], $db_creds);
} }
@@ -419,7 +419,8 @@ class Importer
['icao' => $row->icao, ['icao' => $row->icao,
'subfleet_id' => $subfleet->id, 'subfleet_id' => $subfleet->id,
'active' => $row->enabled, 'active' => $row->enabled,
]); ]
);
$this->addMapping('aircraft', $row->id, $aircraft->id); $this->addMapping('aircraft', $row->id, $aircraft->id);
@@ -682,14 +683,22 @@ class Importer
// Decide which state they will be in accordance with v7 // Decide which state they will be in accordance with v7
if ($state === $phpvms_classic_states['ACTIVE']) { if ($state === $phpvms_classic_states['ACTIVE']) {
return UserState::ACTIVE; return UserState::ACTIVE;
} elseif ($state === $phpvms_classic_states['INACTIVE']) { }
if ($state === $phpvms_classic_states['INACTIVE']) {
// TODO: Make an inactive state? // TODO: Make an inactive state?
return UserState::REJECTED; return UserState::REJECTED;
} elseif ($state === $phpvms_classic_states['BANNED']) { }
if ($state === $phpvms_classic_states['BANNED']) {
return UserState::SUSPENDED; return UserState::SUSPENDED;
} elseif ($state === $phpvms_classic_states['ON_LEAVE']) { }
if ($state === $phpvms_classic_states['ON_LEAVE']) {
return UserState::ON_LEAVE; return UserState::ON_LEAVE;
} }
$this->error('Unknown status: '.$state); $this->error('Unknown status: '.$state);
return UserState::ACTIVE;
} }
} }

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Contracts;
use App\Models\Airport;
abstract class AirportLookup
{
/**
* Lookup the information for an airport. Needs to return an instance of the
* Airport model, or an array with the properties listed in the Airport model.
*
* The in-use implementation can be changed in the config/phpvms.php file, so
* different services can be used, in-case vaCentral one isn't working or there
* is a better one available. Don't handle any caching in this layer, that happens
* at the service layer
*
* Return null if there's an error or nothing was found
*
* @example App\Services\AirportLookup\VaCentralLookup
*
* @param string $icao
*
* @return Airport|null
*/
abstract public function getAirport($icao);
}

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use App\Facades\Utils; use App\Facades\Utils;
use App\Models\Award as AwardModel; use App\Models\Award as AwardModel;

View File

@@ -1,8 +1,8 @@
<?php <?php
namespace App\Console; namespace App\Contracts;
use Log; use Illuminate\Support\Facades\Log;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
/** /**
@@ -16,15 +16,25 @@ abstract class Command extends \Illuminate\Console\Command
abstract public function handle(); abstract public function handle();
/** /**
* Splice the logger and replace the active handlers with * Adjust the logging depending on where we're running from
* the handlers from the "cron" stack in config/logging.php
*
* Close out any of the existing handlers so we don't leave
* file descriptors leaking around
*
* @param string $channel_name Channel name to grab the handlers from
*/ */
public function redirectLoggingToStdout($channel_name): void public function __construct()
{
parent::__construct();
// Running in the console but not in the tests
if (app()->runningInConsole() && env('APP_ENV') !== 'testing') {
$this->redirectLoggingToFile('stdout');
}
}
/**
* Splice the logger and replace the active handlers with the handlers from the
* a stack in config/logging.php
*
* @param string $channel_name Channel name from config/logging.php
*/
public function redirectLoggingToFile($channel_name): void
{ {
$logger = app(\Illuminate\Log\Logger::class); $logger = app(\Illuminate\Log\Logger::class);

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
/** /**
* Borrowed some ideas from myclabs/php-enum after this was created * Borrowed some ideas from myclabs/php-enum after this was created

View File

@@ -1,14 +1,12 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
/** /**
* Class FormRequest * Class FormRequest
*/ */
class FormRequest extends \Illuminate\Foundation\Http\FormRequest class FormRequest extends \Illuminate\Foundation\Http\FormRequest
{ {
protected $sanitizer;
/** /**
* @return bool * @return bool
*/ */

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use App\Models\Airline; use App\Models\Airline;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
/** /**
* Class Listener * Class Listener

55
app/Contracts/Metar.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
namespace App\Contracts;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
/**
* Base class for implementing retrieving METARs
*/
abstract class Metar
{
/**
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
* since this shouldn't be directly called. Call `get_metar($icao)` instead
*
* @param $icao
*
* @return mixed
*/
abstract protected function metar($icao): string;
/**
* Download the METAR, wrap in caching
*
* @param $icao
*
* @return string
*/
public function get_metar($icao): string
{
$cache = config('cache.keys.WEATHER_LOOKUP');
$key = $cache['key'].$icao;
if (Cache::has($key)) {
$raw_metar = Cache::get($key);
if ($raw_metar !== '') {
return $raw_metar;
}
}
try {
$raw_metar = $this->metar($icao);
} catch (\Exception $e) {
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
return '';
}
if ($raw_metar !== '') {
Cache::put($key, $raw_metar, $cache['time']);
}
return $raw_metar;
}
}

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use DB; use DB;

View File

@@ -1,12 +1,14 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
/** /**
* Class Model * Class Model
* *
* @property mixed $id * @property mixed $id
* @property bool $skip_mutator * @property bool $skip_mutator
*
* @method static where(array $array)
*/ */
abstract class Model extends \Illuminate\Database\Eloquent\Model abstract class Model extends \Illuminate\Database\Eloquent\Model
{ {

View File

@@ -1,13 +1,11 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
use Prettus\Repository\Eloquent\BaseRepository;
/** abstract class Repository extends BaseRepository
* Class Repository
*/
abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
{ {
/** /**
* @param $id * @param $id
@@ -108,4 +106,32 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
return $q; return $q;
}); });
} }
/**
* Retrieve all data of repository, paginated. Added in extra parameter to read from the
* request which page it should be on
*
* @param null $limit
* @param array $columns
* @param string $method
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return mixed
*/
public function paginate($limit = null, $columns = ['*'], $method = 'paginate')
{
$this->applyCriteria();
$this->applyScope();
$max = config('repository.pagination.limit', 50);
$limit = (int) ($limit ?? request()->query('limit') ?? $max);
$page = (int) request()->query('page', 1);
$results = $this->model->{$method}($limit, $columns, 'page', $page);
$results->appends(app('request')->query());
$this->resetModel();
return $this->parserResult($results);
}
} }

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Contracts;
/**
* Abstract class for finding a route from a departure airport to an arrival airport
* Can allow for multiple, configurable methods for finding a route, whether it reaches
* out to a REST API or implement some sort of internal logic to look through a file
* or whatever the logic might be.
*
* Just one public-facing method needs to be implemented
*/
abstract class RouteFinder
{
/**
* Find a route from the departure ICAO to the arrival ICAO
*
* @param $dptIcao
* @param $arrIcao
*
* @return string
*/
abstract public function findRoute($dptIcao, $arrIcao): string;
}

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
/** /**
* Class Service * Class Service

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use ArrayAccess; use ArrayAccess;
@@ -20,18 +20,19 @@ class Unit implements ArrayAccess
/** /**
* All of the units of this class * All of the units of this class
*
* @var array
*/ */
public $units; public $units;
/** /**
* Holds an instance of the PhpUnit type * Holds an instance of the PhpUnit type
*
* @var
*/ */
protected $instance; protected $instance;
/**
* Units that are included as part of the REST response
*/
public $responseUnits = [];
/** /**
* @return mixed * @return mixed
*/ */
@@ -40,6 +41,31 @@ class Unit implements ArrayAccess
return $this->__toString(); return $this->__toString();
} }
/**
* Just call toUnit() on the PhpUnitOfMeasure instance
*
* @param string $unit
*
* @return mixed
*/
public function toUnit($unit)
{
return $this->instance->toUnit($unit);
}
/**
* Return all of the units that get sent back in a response
*/
public function getResponseUnits(): array
{
$response = [];
foreach ($this->responseUnits as $unit) {
$response[$unit] = $this[$unit];
}
return $response;
}
/** /**
* Implements ArrayAccess * Implements ArrayAccess
* *
@@ -61,7 +87,7 @@ class Unit implements ArrayAccess
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->units[$offset]; return round($this->instance->toUnit($offset), 2);
} }
/** /**
@@ -72,7 +98,7 @@ class Unit implements ArrayAccess
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
$this->units[$offset] = $value; // $this->units[$offset] = $value;
} }
/** /**
@@ -82,7 +108,7 @@ class Unit implements ArrayAccess
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
$this->units[$offset] = null; // $this->units[$offset] = null;
} }
/** /**

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Interfaces; namespace App\Contracts;
use Arrilot\Widgets\AbstractWidget; use Arrilot\Widgets\AbstractWidget;

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Hourly; namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly; use App\Events\CronHourly;
use App\Interfaces\Listener;
use App\Models\Bid; use App\Models\Bid;
use Carbon\Carbon; use Carbon\Carbon;

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Hourly; namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly; use App\Events\CronHourly;
use App\Interfaces\Listener;
use App\Models\Pirep; use App\Models\Pirep;
use Carbon\Carbon; use Carbon\Carbon;

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Monthly; namespace App\Cron\Monthly;
use App\Contracts\Listener;
use App\Events\CronMonthly; use App\Events\CronMonthly;
use App\Interfaces\Listener;
use App\Models\Enums\ExpenseType; use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService; use App\Services\Finance\RecurringFinanceService;

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Nightly; namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Enums\ExpenseType; use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService; use App\Services\Finance\RecurringFinanceService;

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Services\VersionService;
/**
* Determine if any pilots should be set to ON LEAVE status
*/
class NewVersionCheck extends Listener
{
private $versionSvc;
/**
* @param VersionService $versionSvc
*/
public function __construct(VersionService $versionSvc)
{
$this->versionSvc = $versionSvc;
}
/**
* Set any users to being on leave after X days
*
* @param CronNightly $event
*/
public function handle(CronNightly $event): void
{
$this->versionSvc->isNewVersionAvailable();
}
}

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Nightly; namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Enums\UserState; use App\Models\Enums\UserState;
use App\Models\User; use App\Models\User;
use App\Services\UserService; use App\Services\UserService;

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Nightly; namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Journal; use App\Models\Journal;
use App\Repositories\JournalRepository; use App\Repositories\JournalRepository;
use Log; use Log;

View File

@@ -2,24 +2,20 @@
namespace App\Cron\Nightly; namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Enums\UserState;
use App\Repositories\UserRepository;
use App\Services\UserService; use App\Services\UserService;
use Log; use Illuminate\Support\Facades\Log;
/** /**
* This recalculates the balances on all of the journals * This recalculates the balances on all of the journals
*/ */
class RecalculateStats extends Listener class RecalculateStats extends Listener
{ {
private $userRepo;
private $userSvc; private $userSvc;
public function __construct(UserRepository $userRepo, UserService $userService) public function __construct(UserService $userService)
{ {
$this->userRepo = $userRepo;
$this->userSvc = $userService; $this->userSvc = $userService;
} }
@@ -35,14 +31,7 @@ class RecalculateStats extends Listener
{ {
Log::info('Recalculating balances'); Log::info('Recalculating balances');
$w = [ $this->userSvc->recalculateAllUserStats();
['state', '!=', UserState::REJECTED],
];
$users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']);
foreach ($users as $user) {
$this->userSvc->recalculateStats($user);
}
Log::info('Done recalculating stats'); Log::info('Done recalculating stats');
} }

View File

@@ -2,8 +2,8 @@
namespace App\Cron\Nightly; namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Enums\Days; use App\Models\Enums\Days;
use App\Models\Flight; use App\Models\Flight;
use Carbon\Carbon; use Carbon\Carbon;

View File

@@ -48,8 +48,8 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
'lon' => $faker->longitude, 'lon' => $faker->longitude,
'hub' => false, 'hub' => false,
'ground_handling_cost' => $faker->randomFloat(2, 0, 500), 'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100), 'fuel_100ll_cost' => $faker->randomFloat(2, 1, 10),
'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100), 'fuel_jeta_cost' => $faker->randomFloat(2, 1, 10),
'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100), 'fuel_mogas_cost' => $faker->randomFloat(2, 1, 10),
]; ];
}); });

View File

@@ -22,7 +22,7 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
'alt_airport_id' => function () { 'alt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id; return factory(App\Models\Airport::class)->create()->id;
}, },
'distance' => $faker->numberBetween(0, 3000), 'distance' => $faker->numberBetween(1, 1000),
'route' => null, 'route' => null,
'level' => 0, 'level' => 0,
'dpt_time' => $faker->time(), 'dpt_time' => $faker->time(),
@@ -35,7 +35,7 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
'start_date' => null, 'start_date' => null,
'end_date' => null, 'end_date' => null,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'), 'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $flight) { 'updated_at' => static function (array $flight) {
return $flight['created_at']; return $flight['created_at'];
}, },
]; ];

View File

@@ -1,5 +1,8 @@
<?php <?php
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use Carbon\Carbon; use Carbon\Carbon;
use Faker\Generator as Faker; use Faker\Generator as Faker;
@@ -7,10 +10,15 @@ use Faker\Generator as Faker;
* Create a new PIREP * Create a new PIREP
*/ */
$factory->define(App\Models\Pirep::class, function (Faker $faker) { $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,
]);
return [ return [
'id' => $faker->unique()->numberBetween(10, 10000000), 'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () { 'airline_id' => function () use ($airline) {
return factory(App\Models\Airline::class)->create()->id; return $airline->id;
}, },
'user_id' => function () { 'user_id' => function () {
return factory(App\Models\User::class)->create()->id; return factory(App\Models\User::class)->create()->id;
@@ -18,18 +26,19 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
'aircraft_id' => function () { 'aircraft_id' => function () {
return factory(App\Models\Aircraft::class)->create()->id; return factory(App\Models\Aircraft::class)->create()->id;
}, },
'flight_number' => function (array $pirep) { 'flight_id' => function () use ($flight) {
return factory(App\Models\Flight::class)->create([ return $flight->id;
'airline_id' => $pirep['airline_id'], },
])->flight_number; 'flight_number' => function () use ($flight) {
return $flight->flight_number;
}, },
'route_code' => null, 'route_code' => null,
'route_leg' => null, 'route_leg' => null,
'dpt_airport_id' => function () { 'dpt_airport_id' => function () use ($flight) {
return factory(App\Models\Airport::class)->create()->id; return $flight->dpt_airport_id;
}, },
'arr_airport_id' => function () { 'arr_airport_id' => function () use ($flight) {
return factory(App\Models\Airport::class)->create()->id; return $flight->arr_airport_id;
}, },
'level' => $faker->numberBetween(20, 400), 'level' => $faker->numberBetween(20, 400),
'distance' => $faker->randomFloat(2, 0, 6000), 'distance' => $faker->randomFloat(2, 0, 6000),
@@ -37,16 +46,18 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
'flight_time' => $faker->numberBetween(60, 360), 'flight_time' => $faker->numberBetween(60, 360),
'planned_flight_time' => $faker->numberBetween(60, 360), 'planned_flight_time' => $faker->numberBetween(60, 360),
'zfw' => $faker->randomFloat(2), 'zfw' => $faker->randomFloat(2),
'block_fuel' => $faker->randomFloat(2, 0, 30000), 'block_fuel' => $faker->randomFloat(2, 0, 1000),
'fuel_used' => $faker->randomFloat(2, 0, 30000), 'fuel_used' => function (array $pirep) {
'block_on_time' => Carbon::now('UTC'), return round($pirep['block_fuel'] * .9, 2); // 90% of the fuel loaded was used
'block_off_time' => function (array $pirep) { },
'block_on_time' => Carbon::now('UTC'),
'block_off_time' => function (array $pirep) {
return $pirep['block_on_time']->subMinutes($pirep['flight_time']); return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
}, },
'route' => $faker->text(200), 'route' => $faker->text(200),
'notes' => $faker->text(200), 'notes' => $faker->text(200),
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]), 'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'source_name' => 'Test Factory', 'source_name' => 'TestFactory',
'state' => PirepState::PENDING, 'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED, 'status' => PirepStatus::SCHEDULED,
'submitted_at' => Carbon::now('UTC')->toDateTimeString(), 'submitted_at' => Carbon::now('UTC')->toDateTimeString(),

View File

@@ -8,6 +8,7 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'pilot_id' => 0,
'name' => $faker->name, 'name' => $faker->name,
'email' => $faker->safeEmail, 'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'), 'password' => $password ?: $password = Hash::make('secret'),

View File

@@ -1,15 +1,16 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use App\Services\Installer\SeederService;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateSettingsTable extends Migration class CreateSettingsTable extends Migration
{ {
private $migrationSvc; private $seederSvc;
public function __construct() public function __construct()
{ {
$this->migrationSvc = new \Modules\Installer\Services\MigrationService(); $this->seederSvc = app(SeederService::class);
} }
/** /**
@@ -37,7 +38,7 @@ class CreateSettingsTable extends Migration
$table->timestamps(); $table->timestamps();
}); });
$this->migrationSvc->updateAllSettings(); $this->seederSvc->syncAllSettings();
} }
/** /**

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class RolesPermissionsTables extends Migration class RolesPermissionsTables extends Migration
@@ -74,11 +74,6 @@ class RolesPermissionsTables extends Migration
'name' => 'admin', 'name' => 'admin',
'display_name' => 'Administrators', 'display_name' => 'Administrators',
], ],
[
'id' => 2,
'name' => 'user',
'display_name' => 'Pilot',
],
]; ];
$this->addData('roles', $roles); $this->addData('roles', $roles);

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateAirlinesTable extends Migration class CreateAirlinesTable extends Migration

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use App\Models\Enums\AircraftState; use App\Models\Enums\AircraftState;
use App\Models\Enums\AircraftStatus; use App\Models\Enums\AircraftStatus;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateFaresTable extends Migration class CreateFaresTable extends Migration

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateAirportsTable extends Migration class CreateAirportsTable extends Migration

View File

@@ -1,6 +1,7 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use App\Contracts\Model;
use App\Models\Enums\FlightType; use App\Models\Enums\FlightType;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -14,7 +15,7 @@ class CreateFlightTables extends Migration
public function up() public function up()
{ {
Schema::create('flights', function (Blueprint $table) { Schema::create('flights', function (Blueprint $table) {
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('id', Model::ID_MAX_LENGTH);
$table->unsignedInteger('airline_id'); $table->unsignedInteger('airline_id');
$table->unsignedInteger('flight_number'); $table->unsignedInteger('flight_number');
$table->string('route_code', 5)->nullable(); $table->string('route_code', 5)->nullable();
@@ -47,7 +48,7 @@ class CreateFlightTables extends Migration
}); });
Schema::create('flight_fare', function (Blueprint $table) { Schema::create('flight_fare', function (Blueprint $table) {
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('flight_id', Model::ID_MAX_LENGTH);
$table->unsignedInteger('fare_id'); $table->unsignedInteger('fare_id');
$table->string('price', 10)->nullable(); $table->string('price', 10)->nullable();
$table->string('cost', 10)->nullable(); $table->string('cost', 10)->nullable();
@@ -71,7 +72,7 @@ class CreateFlightTables extends Migration
*/ */
Schema::create('flight_field_values', function (Blueprint $table) { Schema::create('flight_field_values', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('flight_id', Model::ID_MAX_LENGTH);
$table->string('name', 50); $table->string('name', 50);
$table->string('slug', 50)->nullable(); $table->string('slug', 50)->nullable();
$table->text('value'); $table->text('value');
@@ -83,7 +84,7 @@ class CreateFlightTables extends Migration
Schema::create('flight_subfleet', function (Blueprint $table) { Schema::create('flight_subfleet', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->unsignedInteger('subfleet_id'); $table->unsignedInteger('subfleet_id');
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('flight_id', Model::ID_MAX_LENGTH);
$table->index(['subfleet_id', 'flight_id']); $table->index(['subfleet_id', 'flight_id']);
$table->index(['flight_id', 'subfleet_id']); $table->index(['flight_id', 'subfleet_id']);

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateRanksTable extends Migration class CreateRanksTable extends Migration
@@ -28,21 +28,6 @@ class CreateRanksTable extends Migration
$table->unique('name'); $table->unique('name');
}); });
/**
* Initial required data...
*/
$ranks = [
[
'id' => 1,
'name' => 'New Pilot',
'hours' => 0,
'acars_base_pay_rate' => 50,
'manual_base_pay_rate' => 25,
],
];
$this->addData('ranks', $ranks);
} }
/** /**

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**

View File

@@ -1,6 +1,7 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use App\Contracts\Model;
use App\Models\Enums\FlightType; use App\Models\Enums\FlightType;
use App\Models\Enums\PirepState; use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus; use App\Models\Enums\PirepStatus;
@@ -16,7 +17,7 @@ class CreatePirepTables extends Migration
public function up() public function up()
{ {
Schema::create('pireps', function (Blueprint $table) { Schema::create('pireps', function (Blueprint $table) {
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('id', Model::ID_MAX_LENGTH);
$table->unsignedInteger('user_id'); $table->unsignedInteger('user_id');
$table->unsignedInteger('airline_id'); $table->unsignedInteger('airline_id');
$table->unsignedInteger('aircraft_id')->nullable(); $table->unsignedInteger('aircraft_id')->nullable();
@@ -57,7 +58,7 @@ class CreatePirepTables extends Migration
Schema::create('pirep_comments', function (Blueprint $table) { Schema::create('pirep_comments', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('pirep_id', Model::ID_MAX_LENGTH);
$table->unsignedInteger('user_id'); $table->unsignedInteger('user_id');
$table->text('comment'); $table->text('comment');
$table->timestamps(); $table->timestamps();
@@ -65,7 +66,7 @@ class CreatePirepTables extends Migration
Schema::create('pirep_fares', function (Blueprint $table) { Schema::create('pirep_fares', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('pirep_id', Model::ID_MAX_LENGTH);
$table->unsignedInteger('fare_id'); $table->unsignedInteger('fare_id');
$table->unsignedInteger('count')->nullable()->default(0); $table->unsignedInteger('count')->nullable()->default(0);
@@ -81,7 +82,7 @@ class CreatePirepTables extends Migration
Schema::create('pirep_field_values', function (Blueprint $table) { Schema::create('pirep_field_values', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('pirep_id', Model::ID_MAX_LENGTH);
$table->string('name', 50); $table->string('name', 50);
$table->string('slug', 50)->nullable(); $table->string('slug', 50)->nullable();
$table->string('value')->nullable(); $table->string('value')->nullable();

View File

@@ -1,6 +1,7 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use App\Contracts\Model;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -16,7 +17,7 @@ class CreateBidsTable extends Migration
Schema::create('bids', function (Blueprint $table) { Schema::create('bids', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedInteger('user_id'); $table->unsignedInteger('user_id');
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('flight_id', Model::ID_MAX_LENGTH);
$table->timestamps(); $table->timestamps();
$table->index('user_id'); $table->index('user_id');

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -15,7 +15,7 @@ class CreateAcarsTables extends Migration
{ {
Schema::create('acars', function (Blueprint $table) { Schema::create('acars', function (Blueprint $table) {
$table->string('id', 12); $table->string('id', 12);
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('pirep_id', \App\Contracts\Model::ID_MAX_LENGTH);
$table->unsignedTinyInteger('type'); $table->unsignedTinyInteger('type');
$table->unsignedInteger('nav_type')->nullable(); $table->unsignedInteger('nav_type')->nullable();
$table->unsignedInteger('order')->default(0); $table->unsignedInteger('order')->default(0);

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class CreateStatsTable extends Migration class CreateStatsTable extends Migration

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@@ -1,6 +1,6 @@
<?php <?php
use App\Interfaces\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -14,7 +14,7 @@ class CreateFilesTable extends Migration
public function up() public function up()
{ {
Schema::create('files', function (Blueprint $table) { Schema::create('files', function (Blueprint $table) {
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH); $table->string('id', \App\Contracts\Model::ID_MAX_LENGTH);
$table->string('name'); $table->string('name');
$table->string('description')->nullable(); $table->string('description')->nullable();
$table->string('disk')->nullable(); $table->string('disk')->nullable();

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddReadonlyToRoles extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('roles', static function (Blueprint $table) {
$table->boolean('read_only')->default(false);
});
// Set the two main roles as read-only
DB::table('roles')
->whereIn('name', ['admin', 'user'])
->update(['read_only' => true]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('roles', static function (Blueprint $table) {
$table->dropColumn('read_only');
});
}
}

View File

@@ -0,0 +1,66 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class UsersAddPilotId extends Migration
{
/**
* Kinda of gross operations to change the pilot ID column
* 1. Add an `pilot_id` column, which will get populated with the current ID
* 2. Drop the `id` column, and then recreate it as a string field
* 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 void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->unsignedBigInteger('pilot_id')
->after('id')
->unique()
->nullable()
->index('users_pilot_id');
});
// Migrate the current pilot IDs
DB::update('UPDATE `users` SET `pilot_id`=`id`');
// Drop the old ID column and add a new one
/*Schema::table('users', function (Blueprint $table) {
$table->dropPrimary('users_id_primary');
$table->dropColumn('id');
$table->string('id', Model::ID_MAX_LENGTH)->primary();
});
// Update the users to use the `pilot_id` (so we don't need to migrate data from other tables)
$users = DB::table('users')->get(['id']);
foreach ($users as $user) {
$user->id = $user->pilot_id;
$user->save();
}*/
// role_user
// permission_user
// sessions
// pireps
// bids
// news
// user_awards
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('pilot_id');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use App\Models\Enums\PirepState;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class PirepsChangeStateType extends Migration
{
/**
* Change the PIREP state column to be a TINYINT
*
* @return void
*/
public function up()
{
// Migrate the old rejected state
DB::update('UPDATE `pireps` SET `state`='.PirepState::REJECTED
.' WHERE state=-1');
// Change the column type to an unsigned small int (tinyint not supported on all)
Schema::table('pireps', function (Blueprint $table) {
$table->unsignedSmallInteger('state')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}

View File

@@ -0,0 +1,31 @@
<?php
use App\Contracts\Model;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class PirepsAddFlightId extends Migration
{
/**
* Add a `flight_id` column to the PIREPs table
*/
public function up()
{
Schema::table('pireps', function (Blueprint $table) {
$table->string('flight_id', Model::ID_MAX_LENGTH)->nullable()->after('aircraft_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('pireps', function (Blueprint $table) {
$table->dropColumn('flight_id');
});
}
}

View File

@@ -1,20 +1,16 @@
<?php <?php
use App\Services\DatabaseService; use App\Services\Installer\SeederService;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
/** private $seederService;
* Map these other environments to a specific seed file
* public function __construct()
* @var array {
*/ $this->seederService = app(SeederService::class);
public static $seed_mapper = [ }
'local' => 'dev',
'qa' => 'dev',
'staging' => 'dev',
];
/** /**
* Run the database seeds. * Run the database seeds.
@@ -23,18 +19,6 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$env = App::environment(); $this->seederService->syncAllSeeds();
if (array_key_exists($env, self::$seed_mapper)) {
$env = self::$seed_mapper[$env];
}
$path = database_path('seeds/'.$env.'.yml');
if (!file_exists($path)) {
$path = database_path('seeds/prod.yml');
}
$svc = app(DatabaseService::class);
$svc->seed_from_yaml_file($path);
} }
} }

View File

@@ -1,49 +0,0 @@
acars:
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: TNV
lat: 30.28852
lon: -96.058239
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: IAH
lat: 29.95691
lon: -95.345719
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: LCH
lat: 30.14151
lon: -93.105569
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: MEI
lat: 32.37843
lon: -88.804267
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: ATL
lat: 33.62907
lon: -84.435064
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: SIE
lat: 39.0955
lon: -74.800344
created_at: now
updated_at: now

View File

@@ -1,16 +0,0 @@
#
# Initial minimal data required. You probably don't
# want to modify or erase any of this here
#
airports:
- id: KAUS
iata: AUS
icao: KAUS
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1

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