Compare commits

..
Author SHA1 Message Date
Nabeel Shahzad e4a42c53ba Build new assets 2022-08-22 12:42:52 -05:00
Nabeel Shahzad a4b90fcce3 Add colors to the maps options 2022-08-22 12:39:31 -05:00
3270 changed files with 43205 additions and 79786 deletions
-4
View File
@@ -1,10 +1,6 @@
# #
root = true root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.js] [*.js]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env bash
if test "$GIT_TAG_NAME"; then
export VERSION=$GIT_TAG_NAME
# Pass in the tag as the version to write out
php artisan phpvms:version --write --write-full-version "${VERSION}"
export FULL_VERSION=$(php artisan phpvms:version)
else
export BRANCH=${GITHUB_REF##*/}
echo "On branch $BRANCH"
# Write the version out but place the branch ID in there
# This is only for the dev branch
export BASE_VERSION=$(php artisan phpvms:version --base-only)
# This now includes the pre-release version, so "-dev" by default
export VERSION=${BASE_VERSION}
# Don't pass in a version here, just write out the latest hash
php artisan phpvms:version --write "${VERSION}"
export FULL_VERSION=$(php artisan phpvms:version)
fi
export FILE_NAME="phpvms-${VERSION}"
export TAR_NAME="$FILE_NAME.tar.gz"
export ZIP_NAME="$FILE_NAME.zip"
export BASE_DIR=`pwd`
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV
echo "TAR_NAME=${TAR_NAME}" >> $GITHUB_ENV
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
echo "BASE_DIR=${BASE_DIR}" >> $GITHUB_ENV
echo "DISCORD_MSG=Version ${FULL_VERSION} is available, download: [zip](http://downloads.phpvms.net/$ZIP_NAME) | [tar](http://downloads.phpvms.net/$TAR_NAME)" >> $GITHUB_ENV
-249
View File
@@ -1,249 +0,0 @@
name: 'Build'
on: ['push', 'pull_request', 'workflow_dispatch', 'release']
jobs:
build:
runs-on: ubuntu-18.04
if: github.repository == 'nabeelio/phpvms'
strategy:
fail-fast: true
matrix:
php-versions: ['7.3', '7.4']
name: PHP ${{ matrix.php-versions }}
env:
extensions: intl, pcov, mbstring
key: cache-v1
steps:
- name: Checkout
uses: actions/checkout@v2
# Configure Caching
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# Configure PHP
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
ini-values: post_max_size=256M, short_open_tag=On
coverage: xdebug
tools: php-cs-fixer, phpunit
- name: Shutdown Ubuntu MySQL
run: sudo service mysql stop
- name: Install MariaDB
uses: getong/mariadb-action@v1.1
with:
character set server: 'utf8'
collation server: 'utf8_general_ci'
mysql database: 'phpvms'
mysql root password: ''
mysql user: ''
mysql password: ''
- name: Configure Environment
run: |
php --version
mysql --version
# Downgrade composer version to 1.x
composer install --dev --no-interaction --verbose
cp .github/scripts/env.php env.php
cp .github/scripts/phpunit.xml phpunit.xml
php artisan database:create --reset
php artisan migrate:refresh --seed
- name: Run Tests
run: |
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
# distro, and then creates the artifact to push up to S3 or wherever
artifacts:
name: 'Create dev build'
needs: build
runs-on: 'ubuntu-18.04'
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: olegtarasov/get-tag@v2.1
id: tagName
# Configure Caching
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# Dependencies
- name: 'Install Release Dependencies'
run: |
rm -rf vendor
sudo npm i tar-to-zip -g
composer install --no-dev --prefer-dist --no-interaction --verbose
sudo chmod +x ./.github/scripts/*
- name: Get version
run: .github/scripts/version.sh
- name: Build Distro
run: .github/scripts/build.sh
- name: Upload S3
uses: shallwefootball/s3-upload-action@v1.1.3
with:
aws_key_id: ${{ secrets.S3_BUILD_ARTIFACTS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.S3_BUILD_ARTIFACTS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.S3_BUCKET_NAME }}
source_dir: 'dist'
destination_dir: ''
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.3.0
with:
# DISCORD_MSG is defined in versions.sh
args: '{{ DISCORD_MSG }}'
# This runs after all of the tests, run have run. Creates a cleaned up version of the
# distro, and then creates the artifact to push up to S3 or wherever
# https://github.com/actions/create-release
release:
name: 'Create Release'
needs: build
runs-on: 'ubuntu-18.04'
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: olegtarasov/get-tag@v2.1
id: tagName
# Configure Caching
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# Dependencies
- name: 'Install Release Dependencies'
run: |
rm -rf vendor
sudo npm i tar-to-zip -g
composer install --no-dev --prefer-dist --no-interaction --verbose
sudo chmod +x ./.github/scripts/*
- name: Get version
run: .github/scripts/version.sh
- name: Build Distro
run: .github/scripts/build.sh
- name: Upload S3
uses: shallwefootball/s3-upload-action@v1.1.3
with:
aws_key_id: ${{ secrets.S3_BUILD_ARTIFACTS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.S3_BUILD_ARTIFACTS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.S3_BUCKET_NAME }}
source_dir: 'dist'
destination_dir: ''
- name: Checkout code
uses: actions/checkout@v2
- name: Get version
run: .github/scripts/version.sh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
# Upload the tar file to the release
- name: Upload Tar Asset
id: upload-tar-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/{{TAR_NAME}}
asset_name: '{{ TAR_NAME }}'
asset_content_type: application/gzip
# upload the zip file to the release
- name: Upload Zip Asset
id: upload-zip-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/{{ZIP_NAME}}
asset_name: '{{ ZIP_NAME }}'
asset_content_type: application/zip
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.3.0
with:
# DISCORD_MSG is defined in versions.sh
args: '{{ DISCORD_MSG }}'
+2 -1
View File
@@ -30,6 +30,8 @@ env.php
Homestead.json Homestead.json
LocalValetDriver.php LocalValetDriver.php
docker-compose-profiler.yml docker-compose-profiler.yml
sync.sh
.env.*
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/ .rocketeer/
@@ -74,5 +76,4 @@ error_log
.sass-cache .sass-cache
.DS_Store .DS_Store
/config.php /config.php
/config.bak.php
/VERSION /VERSION
-2
View File
@@ -28,8 +28,6 @@ RedirectMatch 403 ^/composer.phar
RedirectMatch 403 ^/env.php.*?$ RedirectMatch 403 ^/env.php.*?$
RedirectMatch 403 ^/env.php RedirectMatch 403 ^/env.php
RedirectMatch 403 ^/env.php$ RedirectMatch 403 ^/env.php$
RedirectMatch 403 ^/config.php$
RedirectMatch 403 ^/config.bak.php$
RedirectMatch 403 ^/Makefile RedirectMatch 403 ^/Makefile
RedirectMatch 403 ^/package.json RedirectMatch 403 ^/package.json
RedirectMatch 403 ^/package-lock.json RedirectMatch 403 ^/package-lock.json
+161
View File
@@ -0,0 +1,161 @@
#
# Travis CI config file
#
language: php
php:
- '7.4'
- '7.3'
- '7.2'
#env:
# - DB=mysql
# - DB=mariadb
cache:
# Cache lives for 10 min
# Default of 3m might not be long enough for all the runs
timeout: 600
directories:
- "$HOME/.composer/cache"
- "$HOME/.npm"
services:
- mysql
#addons:
# mariadb: '10.2'
install:
- php --version
- mysql --version
- composer install --dev --no-interaction --verbose
- npm i tar-to-zip -g
- 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:
- vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no
- vendor/bin/phpunit --debug --verbose
after_failure:
- cat storage/logs/*.log
# Refer to: https://github.com/doctrine/dbal/blob/master/.travis.yml#L39
jobs:
include:
# Different test stages
# - stage: Test
# name: PHP 7.2 + MySQL 5.7
# php: 7.2
# env: DB=mysql
# services:
# - mysql
# - stage: Test
# name: PHP 7.3 + MySQL 5.7
# php: 7.3
# env: DB=mysql
# services:
# - mysql
# - stage: Test
# name: PHP 7.4 + MySQL 5.7
# php: 7.4
# env: DB=mysql
# services:
# - mysql
# - stage: Test
# name: PHP 7.2 + MariaDB 10.1
# php: 7.2
# env: DB=mariadb
# addons:
# mariadb: '10.1'
# - stage: Test
# name: PHP 7.3 + MariaDB 10.1
# php: 7.3
# env: DB=mariadb
# addons:
# mariadb: '10.1'
# - stage: Test
# name: PHP 7.4 + MariaDB 10.1
# php: 7.4
# env: DB=mariadb MARIADB_VERSION=10.1
# addons:
# mariadb: '10.1'
# - stage: Test
# name: PHP 7.2 + MariaDB 10.2
# php: 7.2
# env: DB=mariadb
# addons:
# mariadb: '10.2'
# - stage: Test
# name: PHP 7.3 + MariaDB 10.3
# php: 7.3
# env: DB=mariadb
# addons:
# mariadb: '10.2'
# - stage: Test
# name: PHP 7.4 + MariaDB 10.2
# php: 7.4
# env: DB=mariadb
# addons:
# mariadb: '10.2'
# - stage: Test
# name: PHP 7.2 + MariaDB 10.3
# php: 7.2
# env: DB=mariadb
# addons:
# mariadb: '10.3'
# - stage: Test
# name: PHP 7.3 + MariaDB 10.3
# php: 7.3
# env: DB=mariadb
# addons:
# mariadb: '10.3'
# - stage: Test
# name: PHP 7.4 + MariaDB 10.3
# php: 7.4
# env: DB=mariadb
# addons:
# mariadb: '10.3'
# Just packages up a release
- stage: package
script: skip
before_deploy:
- 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:
- provider: script
skip_cleanup: true
script: ./.travis/deploy_script.sh
on:
all_branches: true
repo: nabeelio/phpvms
php: '7.4'
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
script: skip
before_deploy:
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
- ./.travis/deploy_script.sh
deploy:
provider: releases
skip_cleanup: true
api_key: $GITHUB_TOKEN
file_glob: true
file: build/*
on:
tags: true
repo: nabeelio/phpvms
php: '7.4'
+71 -7
View File
@@ -1,12 +1,52 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ "$TRAVIS" != "true" ]; then
exit 0
fi
cd $TRAVIS_BUILD_DIR
if test "$TRAVIS_TAG"; then
VERSION=$TRAVIS_TAG
# Pass in the tag as the version to write out
php artisan phpvms:version --write --write-full-version "${VERSION}"
FULL_VERSION=$(php artisan phpvms:version)
else
echo "On branch $TRAVIS_BRANCH"
if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
echo "Not on valid branch, exiting"
exit 0
fi
# Write the version out but place the branch ID in there
# This is only for the dev branch
BASE_VERSION=$(php artisan phpvms:version --base-only)
# This now includes the pre-release version, so "-dev" by default
VERSION=${BASE_VERSION}
# Don't pass in a version here, just write out the latest hash
php artisan phpvms:version --write "${VERSION}"
FULL_VERSION=$(php artisan phpvms:version)
fi
FILE_NAME="phpvms-${VERSION}"
TAR_NAME="$FILE_NAME.tar.gz"
ZIP_NAME="$FILE_NAME.zip"
echo "Version: ${VERSION}" echo "Version: ${VERSION}"
echo "Full Version: ${FULL_VERSION}" echo "Full Version: ${FULL_VERSION}"
echo "Package name: ${TAR_NAME}" echo "Package name: ${TAR_NAME}"
echo "Current directory: ${BASE_DIR}"
echo "==========================="
echo "Cleaning files" echo "Cleaning files"
rm -rf vendor
composer install --no-dev --prefer-dist --no-interaction --verbose
# Leftover individual files to delete # Leftover individual files to delete
declare -a remove_files=( declare -a remove_files=(
.git .git
@@ -67,20 +107,44 @@ mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions mkdir -p storage/framework/sessions
mkdir -p storage/framework/views mkdir -p storage/framework/views
# Regenerate the autoloader and classes
composer dump-autoload
make clean
cd /tmp cd /tmp
ls -al $TRAVIS_BUILD_DIR/../
ls -al $BASE_DIR/../ tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR .
tar -czf $TAR_NAME -C $BASE_DIR .
sha256sum $TAR_NAME >"$TAR_NAME.sha256" sha256sum $TAR_NAME >"$TAR_NAME.sha256"
tar2zip $TAR_NAME tar2zip $TAR_NAME
sha256sum $ZIP_NAME >"$ZIP_NAME.sha256" sha256sum $ZIP_NAME >"$ZIP_NAME.sha256"
ls -al /tmp ls -al /tmp
echo "Moving to dist" echo "Uploading to S3"
mkdir -p $BASE_DIR/dist mkdir -p $TRAVIS_BUILD_DIR/build
cd $BASE_DIR/dist cd $TRAVIS_BUILD_DIR/build
mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256" . mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256" .
artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256 $ZIP_NAME.sha256
# Upload the version for a tagged release. Move to a version file in different
# tags. Within phpVMS, we have an option of which version to track in the admin
if test "$TRAVIS_TAG"; then
echo "Uploading release version file"
cp "$TRAVIS_BUILD_DIR/VERSION" release_version
artifacts upload --target-paths "/" release_version
else
echo "Uploading ${TRAVIS_BRANCH}_version file"
cp $TRAVIS_BUILD_DIR/VERSION ${TRAVIS_BRANCH}_version
artifacts upload --target-paths "/" ${TRAVIS_BRANCH}_version
fi
#if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
# echo "Skipping Discord branch update broadcast"
#else
curl -X POST \
--data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME (${FULL_VERSION})\"}" \
-H "Content-Type: application/json" \
$DISCORD_WEBHOOK_URL
#fi
@@ -1,3 +1,7 @@
<?php
exit();
?>
APP_ENV="dev" APP_ENV="dev"
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY=" APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
APP_URL="http://localhost" APP_URL="http://localhost"
@@ -8,7 +12,7 @@ APP_LOCALE="en"
PHPVMS_INSTALLED="true" PHPVMS_INSTALLED="true"
APP_LOG="daily" APP_LOG="daily"
LOG_LEVEL="debug" APP_LOG_LEVEL="debug"
APP_LOG_MAX_FILES="3" APP_LOG_MAX_FILES="3"
DB_CONNECTION="mysql" DB_CONNECTION="mysql"
@@ -21,9 +21,9 @@
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</whitelist> </whitelist>
</filter> </filter>
<!--<listeners> <listeners>
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/> <listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
</listeners>--> </listeners>
<php> <php>
<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"/>
+1 -2
View File
@@ -2,7 +2,7 @@ FROM php:7.4-fpm-alpine
WORKDIR /var/www/ WORKDIR /var/www/
RUN apk add gmp-dev icu-dev RUN apk add gmp-dev
RUN curl --silent --show-error https://getcomposer.org/installer | php RUN curl --silent --show-error https://getcomposer.org/installer | php
# Copy any config files in # Copy any config files in
@@ -12,7 +12,6 @@ RUN ln -sf /dev/stderr /var/log/fpm-error.log
RUN docker-php-ext-install \ RUN docker-php-ext-install \
calendar \ calendar \
intl \
pdo_mysql \ pdo_mysql \
gmp \ gmp \
opcache && \ opcache && \
+3 -3
View File
@@ -74,9 +74,9 @@ reload-db:
tests: test tests: test
.PHONY: test .PHONY: test
test: test: phpcs
@#php artisan database:create --reset #php artisan database:create --reset
@vendor/bin/phpunit --verbose vendor/bin/phpunit --debug --verbose
.PHONY: phpcs .PHONY: phpcs
phpcs: phpcs:
+15 -12
View File
@@ -1,17 +1,20 @@
# phpVMS <sup>7</sup> # phpvms <sup>7</sup>
[![Build](https://github.com/nabeelio/phpvms/workflows/Build/badge.svg?branch=dev)](https://github.com/nabeelio/phpvms/actions) [![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. The latest documentation, with installation instructions is available [on the phpVMS documentation](https://docs.phpvms.net/) page. The next phpvms version built on the laravel framework. work in progress. The latest documentation, with installation instructions is available
[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.
### Requirements
- PHP 7.3+, extensions:
## Requirements
- PHP 7.1+, extensions:
- cURL - cURL
- JSON - JSON
- mbstring - mbstring
@@ -21,22 +24,22 @@ A full distribution, with all of the composer dependencies, is available at this
- Database: - Database:
- MySQL 5.5+ (or MySQL variant, including MariaDB and Percona) - MySQL 5.5+ (or MySQL variant, including MariaDB and Percona)
[View more details on requirements](https://docs.phpvms.net/requirements) [View more details on requirements](http://docs.phpvms.net/setup/requirements)
### Installer ## Installer
1. Upload to your server 1. Upload to your server
1. Visit the site, and follow the link to the installer 1. Visit the site, and follow the link to the installer
[View installation details](https://docs.phpvms.net/installation/installation) [View installation details](http://docs.phpvms.net/setup/installation)
## Development Environment # development environment
A full development environment can be brought up using Docker: A full development environment can be brought up using Docker:
```bash ```bash
composer install composer install
npm install yarn install
docker-compose build docker-compose build
docker-compose up docker-compose up
``` ```
@@ -47,7 +50,7 @@ Then go to `http://localhost`. If you're using dnsmasq, the `app` container is l
127.0.0.1 phpvms.test 127.0.0.1 phpvms.test
``` ```
### Building JS/CSS assets ## Building JS/CSS assets
Yarn is required, run: Yarn is required, run:
+8 -8
View File
@@ -4,9 +4,9 @@ namespace App\Console\Commands;
use App; use App;
use App\Contracts\Command; use App\Contracts\Command;
use App\Services\Installer\ConfigService;
use App\Services\Installer\SeederService; use App\Services\Installer\SeederService;
use DatabaseSeeder; use DatabaseSeeder;
use Modules\Installer\Services\ConfigService;
/** /**
* Create the config files * Create the config files
@@ -81,13 +81,13 @@ class CreateConfigs extends Command
$this->info('Regenerating the config files'); $this->info('Regenerating the config files');
$cfgSvc->createConfigFiles([ $cfgSvc->createConfigFiles([
'APP_ENV' => 'dev', 'APP_ENV' => 'dev',
'SITE_NAME' => $this->argument('name'), 'SITE_NAME' => $this->argument('name'),
'DB_CONNECTION' => 'mysql', 'DB_CONN' => 'mysql',
'DB_HOST' => $this->argument('db_host'), 'DB_HOST' => $this->argument('db_host'),
'DB_DATABASE' => $this->argument('db_name'), 'DB_NAME' => $this->argument('db_name'),
'DB_USERNAME' => $this->argument('db_user'), 'DB_USER' => $this->argument('db_user'),
'DB_PASSWORD' => $this->argument('db_pass'), 'DB_PASS' => $this->argument('db_pass'),
]); ]);
$this->info('Config files generated!'); $this->info('Config files generated!');
+5 -13
View File
@@ -79,29 +79,21 @@ class CreateDatabase extends Command
*/ */
protected function create_sqlite($dbkey) protected function create_sqlite($dbkey)
{ {
$dbPath = config($dbkey.'database');
// Skip if running in memory
if ($dbPath === ':memory:') {
return;
}
$exec = 'sqlite3'; $exec = 'sqlite3';
if ($this->os->isWindowsLike()) { if ($this->os->isWindowsLike()) {
$exec = 'sqlite3.exe'; $exec = 'sqlite3.exe';
} }
if ($this->option('reset') === true) { if ($this->option('reset') === true) {
if (file_exists($dbPath)) { $cmd = ['rm', '-rf', config($dbkey.'database')];
unlink(config($dbkey.'database')); $this->runCommand($cmd);
}
} }
if (!file_exists($dbPath)) { if (!file_exists(config($dbkey.'database'))) {
$cmd = [ $cmd = [
$exec, $exec,
$dbPath, config($dbkey.'database'),
'".exit"', '""',
]; ];
$this->runCommand($cmd); $this->runCommand($cmd);
+4 -4
View File
@@ -3,7 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Contracts\Command; use App\Contracts\Command;
use App\Services\Installer\ConfigService; use Modules\Installer\Services\ConfigService;
/** /**
* Create a fresh development install * Create a fresh development install
@@ -79,9 +79,9 @@ class DevInstall extends Command
$this->info('Regenerating the config files'); $this->info('Regenerating the config files');
$cfgSvc->createConfigFiles([ $cfgSvc->createConfigFiles([
'APP_ENV' => 'dev', 'APP_ENV' => 'dev',
'SITE_NAME' => 'phpvms test', 'SITE_NAME' => 'phpvms test',
'DB_CONNECTION' => 'sqlite', 'DB_CONN' => 'sqlite',
]); ]);
$this->info('Config files generated!'); $this->info('Config files generated!');
-25
View File
@@ -1,25 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Contracts\Command;
use App\Services\Installer\ConfigService;
/**
* Command to rewrite the config files
*/
class RewriteConfigs extends Command
{
protected $signature = 'phpvms:rewrite-configs';
protected $description = 'Rewrite the config files';
/**
* Run dev related commands
*/
public function handle()
{
/** @var ConfigService $configSvc */
$configSvc = app(ConfigService::class);
$configSvc->rewriteConfigFiles();
}
}
+1 -15
View File
@@ -3,7 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Contracts\Command; use App\Contracts\Command;
use Illuminate\Support\Facades\DB; use DB;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
/** /**
@@ -25,20 +25,6 @@ class YamlExport extends Command
exit(); exit();
} }
// A "preset" for exporting the base set of data
if ($tables[0] === 'base') {
$tables = [
'airlines',
'aircraft',
'subfleets',
'subfleet_fare',
'subfleet_rank',
'bids',
'fares',
'flights',
];
}
$export_tables = []; $export_tables = [];
foreach ($tables as $table) { foreach ($tables as $table) {
$export_tables[$table] = []; $export_tables[$table] = [];
+3 -10
View File
@@ -13,11 +13,7 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/** /**
* Define the application's command schedule. How this works... according to the command * Define the application's command schedule.
* time, an event gets send out with the appropriate time (e.g, hourly sends an hourly event)
*
* Then the CronServiceProvider has the list of cronjobs which then run according to the events
* and then calls those at the proper times.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
* *
@@ -31,13 +27,10 @@ class Kernel extends ConsoleKernel
$schedule->command(Hourly::class)->hourly(); $schedule->command(Hourly::class)->hourly();
// When spatie-backups runs // When spatie-backups runs
/*if (config('backup.backup.enabled', false) === true) { $schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:clean')->daily()->at('01:00'); $schedule->command('backup:run')->daily()->at('02:00');
$schedule->command('backup:run')->daily()->at('02:00');
}*/
// Update the last time the cron was run // Update the last time the cron was run
/** @var CronService $cronSvc */
$cronSvc = app(CronService::class); $cronSvc = app(CronService::class);
$cronSvc->updateLastRunTime(); $cronSvc->updateLastRunTime();
} }
-3
View File
@@ -36,10 +36,7 @@ abstract class Award
* You don't really need to mess with anything below here * You don't really need to mess with anything below here
*/ */
/** @var \App\Models\Award|null */
protected $award; protected $award;
/** @var \App\Models\User|null */
protected $user; protected $user;
public function __construct(AwardModel $award = null, User $user = null) public function __construct(AwardModel $award = null, User $user = null)
+6 -7
View File
@@ -3,7 +3,6 @@
namespace App\Contracts; namespace App\Contracts;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use function is_array;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
/** /**
@@ -83,9 +82,9 @@ abstract class Command extends \Illuminate\Console\Command
} }
/** /**
* @param array|string $cmd * @param $cmd
* @param bool $return * @param bool $return
* @param mixed $verbose * @param mixed $verbose
* *
* @throws \Symfony\Component\Process\Exception\RuntimeException * @throws \Symfony\Component\Process\Exception\RuntimeException
* @throws \Symfony\Component\Process\Exception\LogicException * @throws \Symfony\Component\Process\Exception\LogicException
@@ -94,16 +93,16 @@ abstract class Command extends \Illuminate\Console\Command
*/ */
public function runCommand($cmd, $return = false, $verbose = true): string public function runCommand($cmd, $return = false, $verbose = true): string
{ {
if (is_array($cmd)) { if (\is_array($cmd)) {
$cmd = implode(' ', $cmd); $cmd = implode(' ', $cmd);
} }
if ($verbose) { if ($verbose) {
$this->info('Running '.$cmd); $this->info('Running "'.$cmd.'"');
} }
$val = ''; $val = '';
$process = Process::fromShellCommandline($cmd); $process = new Process($cmd);
$process->run(function ($type, $buffer) use ($return, &$val) { $process->run(function ($type, $buffer) use ($return, &$val) {
if ($return) { if ($return) {
$val .= $buffer; $val .= $buffer;
-12
View File
@@ -1,12 +0,0 @@
<?php
namespace App\Contracts;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class Event
{
use Dispatchable;
use SerializesModels;
}
+4 -4
View File
@@ -3,9 +3,9 @@
namespace App\Contracts; namespace App\Contracts;
use App\Models\Airline; use App\Models\Airline;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Log;
use Validator;
/** /**
* Common functionality used across all of the importers * Common functionality used across all of the importers
@@ -51,9 +51,9 @@ class ImportExport
* *
* @param $code * @param $code
* *
* @return Airline * @return \Illuminate\Database\Eloquent\Model
*/ */
public function getAirline($code): Airline public function getAirline($code)
{ {
$airline = Airline::firstOrCreate([ $airline = Airline::firstOrCreate([
'icao' => $code, 'icao' => $code,
+1 -1
View File
@@ -16,7 +16,7 @@ abstract class Listener
public function subscribe(Dispatcher $events): void public function subscribe(Dispatcher $events): void
{ {
foreach (static::$callbacks as $klass => $cb) { foreach (static::$callbacks as $klass => $cb) {
$events->listen($klass, static::class.'@'.$cb); $events->listen($klass, get_class($this).'@'.$cb);
} }
} }
} }
+5 -49
View File
@@ -12,24 +12,13 @@ abstract class Metar
{ {
/** /**
* Implement retrieving the METAR - return the METAR string. Needs to be protected, * Implement retrieving the METAR - return the METAR string. Needs to be protected,
* since this shouldn't be directly called. Call `metar($icao)`. If not implemented, * since this shouldn't be directly called. Call `get_metar($icao)` instead
* return a blank string
* *
* @param $icao * @param $icao
* *
* @return mixed * @return mixed
*/ */
abstract protected function get_metar($icao): string; abstract protected function metar($icao): string;
/**
* Implement retrieving the TAF - return the string. Call `taf($icao)`. If not implemented,
* return a blank string
*
* @param $icao
*
* @return mixed
*/
abstract protected function get_taf($icao): string;
/** /**
* Download the METAR, wrap in caching * Download the METAR, wrap in caching
@@ -38,9 +27,9 @@ abstract class Metar
* *
* @return string * @return string
*/ */
public function metar($icao): string public function get_metar($icao): string
{ {
$cache = config('cache.keys.METAR_WEATHER_LOOKUP'); $cache = config('cache.keys.WEATHER_LOOKUP');
$key = $cache['key'].$icao; $key = $cache['key'].$icao;
if (Cache::has($key)) { if (Cache::has($key)) {
@@ -51,7 +40,7 @@ abstract class Metar
} }
try { try {
$raw_metar = $this->get_metar($icao); $raw_metar = $this->metar($icao);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace()); Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
return ''; return '';
@@ -63,37 +52,4 @@ abstract class Metar
return $raw_metar; return $raw_metar;
} }
/**
* Download the TAF, wrap in caching
*
* @param $icao
*
* @return string
*/
public function taf($icao): string
{
$cache = config('cache.keys.TAF_WEATHER_LOOKUP');
$key = $cache['key'].$icao;
if (Cache::has($key)) {
$taf = Cache::get($key);
if ($taf !== '') {
return $taf;
}
}
try {
$taf = $this->get_taf($icao);
} catch (\Exception $e) {
Log::error('Error getting TAF: '.$e->getMessage(), $e->getTrace());
return '';
}
if ($taf !== '') {
Cache::put($key, $taf, $cache['time']);
}
return $taf;
}
} }
+3 -47
View File
@@ -3,11 +3,8 @@
namespace App\Contracts; namespace App\Contracts;
use App\Support\Database; use App\Support\Database;
use Exception; use DB;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
/** /**
* Class Migration * Class Migration
@@ -28,29 +25,6 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
{ {
} }
/**
* Add a module and enable it
*
* @param array $attrs
*/
public function addModule(array $attrs)
{
$module = array_merge([
'enabled' => true,
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
], $attrs);
try {
DB::table('modules')->insert($module);
} catch (Exception $e) {
// setting already exists, just ignore it
if ($e->getCode() === 23000) {
return;
}
}
}
/** /**
* Seed a YAML file into the database * Seed a YAML file into the database
* *
@@ -61,7 +35,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
try { try {
$path = base_path($file); $path = base_path($file);
Database::seed_from_yaml_file($path, false); Database::seed_from_yaml_file($path, false);
} catch (Exception $e) { } catch (\Exception $e) {
Log::error('Unable to load '.$file.' file'); Log::error('Unable to load '.$file.' file');
Log::error($e); Log::error($e);
} }
@@ -78,7 +52,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
foreach ($rows as $row) { foreach ($rows as $row) {
try { try {
DB::table($table)->insert($row); DB::table($table)->insert($row);
} catch (Exception $e) { } catch (\Exception $e) {
// setting already exists, just ignore it // setting already exists, just ignore it
if ($e->getCode() === 23000) { if ($e->getCode() === 23000) {
continue; continue;
@@ -86,22 +60,4 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
} }
} }
} }
/**
* Add an award from the migrations (for example, if you're adding an award module)
*
* @param array $award See \App\Models\Awardv
*
* @throws \Illuminate\Validation\ValidationException
*/
public function addAward(array $award)
{
$validator = Validator::make($award, \App\Models\Award::$rules);
if ($validator->fails()) {
throw new ValidationException($validator);
}
$awardModel = new \App\Models\Award($award);
$awardModel->save();
}
} }
-49
View File
@@ -1,49 +0,0 @@
<?php
namespace App\Contracts\Modules;
/**
* Base class for module service providers
* Add-on module service providers must extend this class. Docs on Service Providers:
* https://laravel.com/docs/7.x/providers
*
* For a sample service provider, view the sample module one:
* https://github.com/nabeelio/phpvms-module/blob/master/Providers/SampleServiceProvider.php
*/
abstract class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/**
* A boot method is required, even if it doesn't do anything.
* https://laravel.com/docs/7.x/providers#the-boot-method
*
* This is normally where you'd register the routes or other startup tasks for your module
*/
public function boot(): void
{
}
/**
* This is required to register the links in either the public or admin toolbar
* For example, adding a frontend link:
*
* $this->moduleSvc->addFrontendLink('Sample', '/sample', '', $logged_in=true);
*
* Or an admin link:
*
* $this->moduleSvc->addAdminLink('Sample', '/admin/sample');
*/
public function registerLinks(): void
{
}
/**
* Deferred providers:
* https://laravel.com/docs/7.x/providers#deferred-providers
*
* @return array
*/
public function provides(): array
{
return [];
}
}
+1 -3
View File
@@ -2,12 +2,10 @@
namespace App\Contracts; namespace App\Contracts;
use Illuminate\Http\Resources\Json\JsonResource;
/** /**
* Base class for a resource/response * Base class for a resource/response
*/ */
class Resource extends JsonResource class Resource extends \Illuminate\Http\Resources\Json\Resource
{ {
/** /**
* Iterate through the list of $fields and check if they're a "Unit" * Iterate through the list of $fields and check if they're a "Unit"
-52
View File
@@ -1,52 +0,0 @@
<?php
namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly;
use App\Models\Enums\PirepState;
use App\Models\Pirep;
use App\Services\PirepService;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
/**
* Remove cancelled/deleted PIREPs. Look for PIREPs that were created before the setting time
* (e.g, 12 hours ago) and are marked with the
*/
class DeletePireps extends Listener
{
/**
* Delete old rejected PIREPs
*
* @param CronHourly $event
*
* @throws \Exception
*/
public function handle(CronHourly $event): void
{
$this->deletePireps(setting('pireps.delete_rejected_hours'), PirepState::REJECTED);
$this->deletePireps(setting('pireps.delete_cancelled_hours'), PirepState::CANCELLED);
}
/**
* Look for and delete PIREPs which match the criteria
*
* @param int $expire_time_hours The time in hours to look for PIREPs
* @param int $state The PirepState enum value
*/
protected function deletePireps(int $expire_time_hours, int $state)
{
$dt = Carbon::now('UTC')->subHours($expire_time_hours);
$pireps = Pirep::where('created_at', '<', $dt)->where(['state' => $state])->get();
/** @var PirepService $pirepSvc */
$pirepSvc = app(PirepService::class);
/** @var Pirep $pirep */
foreach ($pireps as $pirep) {
Log::info('Cron: Deleting PIREP id='.$pirep->id.', state='.PirepState::label($state));
$pirepSvc->delete($pirep);
}
}
}
+2 -2
View File
@@ -25,7 +25,7 @@ class RemoveExpiredBids extends Listener
return; return;
} }
$date = Carbon::now('UTC')->subHours(setting('bids.expire_time')); $date = Carbon::now()->subHours(setting('bids.expire_time'));
Bid::where('created_at', '<', $date)->delete(); Bid::whereDate('created_at', '<', $date)->delete();
} }
} }
+2 -2
View File
@@ -26,8 +26,8 @@ class RemoveExpiredLiveFlights extends Listener
return; return;
} }
$date = Carbon::now('UTC')->subHours(setting('acars.live_time')); $date = Carbon::now()->subHours(setting('acars.live_time'));
Pirep::where('updated_at', '<', $date) Pirep::whereDate('updated_at', '<', $date)
->where('state', PirepState::IN_PROGRESS) ->where('state', PirepState::IN_PROGRESS)
->delete(); ->delete();
} }
-2
View File
@@ -6,7 +6,6 @@ use App\Contracts\Listener;
use App\Events\CronMonthly; use App\Events\CronMonthly;
use App\Models\Enums\ExpenseType; use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService; use App\Services\Finance\RecurringFinanceService;
use Illuminate\Support\Facades\Log;
/** /**
* Go through and apply any finances that are daily * Go through and apply any finances that are daily
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
*/ */
public function handle(CronMonthly $event): void public function handle(CronMonthly $event): void
{ {
Log::info('Monthly: Applying monthly expenses');
$this->financeSvc->processExpenses(ExpenseType::MONTHLY); $this->financeSvc->processExpenses(ExpenseType::MONTHLY);
} }
} }
-2
View File
@@ -6,7 +6,6 @@ use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Models\Enums\ExpenseType; use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService; use App\Services\Finance\RecurringFinanceService;
use Illuminate\Support\Facades\Log;
/** /**
* Go through and apply any finances that are daily * Go through and apply any finances that are daily
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Applying daily expenses');
$this->financeSvc->processExpenses(ExpenseType::DAILY); $this->financeSvc->processExpenses(ExpenseType::DAILY);
} }
} }
@@ -5,7 +5,6 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener; use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Services\SimBriefService; use App\Services\SimBriefService;
use Illuminate\Support\Facades\Log;
/** /**
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP * Clear any expired SimBrief flight briefs that aren't attached to a PIREP
@@ -24,7 +23,6 @@ class ClearExpiredSimbrief extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Removing expired Simbrief entries');
$this->simbriefSvc->removeExpiredEntries(); $this->simbriefSvc->removeExpiredEntries();
} }
} }
-2
View File
@@ -5,7 +5,6 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener; use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Services\VersionService; use App\Services\VersionService;
use Illuminate\Support\Facades\Log;
/** /**
* Determine if any pilots should be set to ON LEAVE status * Determine if any pilots should be set to ON LEAVE status
@@ -29,7 +28,6 @@ class NewVersionCheck extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Checking for new version');
$this->versionSvc->isNewVersionAvailable(); $this->versionSvc->isNewVersionAvailable();
} }
} }
+10 -6
View File
@@ -4,8 +4,10 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener; use App\Contracts\Listener;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Models\Enums\UserState;
use App\Models\User;
use App\Services\UserService; use App\Services\UserService;
use Illuminate\Support\Facades\Log; use Carbon\Carbon;
/** /**
* Determine if any pilots should be set to ON LEAVE status * Determine if any pilots should be set to ON LEAVE status
@@ -16,8 +18,6 @@ class PilotLeave extends Listener
/** /**
* PilotLeave constructor. * PilotLeave constructor.
*
* @param UserService $userSvc
*/ */
public function __construct(UserService $userSvc) public function __construct(UserService $userSvc)
{ {
@@ -34,9 +34,13 @@ class PilotLeave extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Cron: Running pilot leave check'); if (setting('pilots.auto_leave_days') === 0) {
$users = $this->userSvc->findUsersOnLeave(); return;
Log::info('Found '.count($users).' users on leave'); }
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
$users = User::where('status', UserState::ACTIVE)
->whereDate('updated_at', '<', $date);
foreach ($users as $user) { foreach ($users as $user) {
Log::info('Setting user '.$user->ident.' to ON LEAVE status'); Log::info('Setting user '.$user->ident.' to ON LEAVE status');
+1 -1
View File
@@ -35,7 +35,7 @@ class RecalculateBalances extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Recalculating balances'); Log::info('Recalculating balances');
$journals = Journal::all(); $journals = Journal::all();
foreach ($journals as $journal) { foreach ($journals as $journal) {
+2 -2
View File
@@ -32,10 +32,10 @@ class RecalculateStats extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Recalculating user stats'); Log::info('Recalculating user stats');
$this->userSvc->recalculateAllUserStats(); $this->userSvc->recalculateAllUserStats();
Log::info('Nightly: Recalcuating aircraft status'); Log::info('Recalcuating aircraft status');
$this->aircraftSvc->recalculateStats(); $this->aircraftSvc->recalculateStats();
} }
} }
+24 -12
View File
@@ -19,8 +19,6 @@ class SetActiveFlights extends Listener
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
Log::info('Nightly: Setting active flights');
$this->checkFlights(); $this->checkFlights();
} }
@@ -44,18 +42,23 @@ class SetActiveFlights extends Listener
continue; continue;
} }
// Set to visible by default
$flight->visible = true;
// dates aren't set, so just save if there were any changes above // dates aren't set, so just save if there were any changes above
// and move onto the next one // and move onto the next one
if ($flight->start_date === null || $flight->end_date === null) { if ($flight->start_date === null || $flight->end_date === null) {
if ($flight->days !== null && $flight->days > 0) { if ($flight->days !== null && $flight->days > 0) {
$flight->visible = Days::isToday($flight->days); $visible = Days::isToday($flight->days);
if (!$flight->visible) { if ($flight->visible !== $visible) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in=' Log::info('Flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden'));
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
$flight->visible = $visible;
if ($visible === false) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
}
} }
} else {
Log::info('Toggling flight '.$flight->ident.' to visible');
$flight->visible = true;
} }
$flight->save(); $flight->save();
@@ -68,11 +71,20 @@ class SetActiveFlights extends Listener
// and then make sure if days of the week are specified, check that too // and then make sure if days of the week are specified, check that too
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) { if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
if ($flight->days !== null && $flight->days > 0) { if ($flight->days !== null && $flight->days > 0) {
$flight->visible = Days::isToday($flight->days); $visible = Days::isToday($flight->days);
if (!$flight->visible) { if ($flight->visible !== $visible) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in=' Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').'');
$flight->visible = $visible;
if ($visible === false) {
Log::info('Today='.date('N').', start='.$flight->start_date
.', end='.$flight->end_date.', mask='.$flight->days.', in='
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')])); .Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
}
} }
} else {
Log::info('Toggling flight '.$flight->ident.' to visible');
$flight->visible = true;
} }
} else { } else {
$flight->visible = false; $flight->visible = false;
+5 -11
View File
@@ -1,30 +1,24 @@
<?php <?php
use App\Models\Airport;
use App\Models\Enums\AircraftState;
use App\Models\Enums\AircraftStatus;
use App\Models\Subfleet;
use App\Support\ICAO;
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(App\Models\Aircraft::class, function (Faker $faker) { $factory->define(App\Models\Aircraft::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'subfleet_id' => function () { 'subfleet_id' => function () {
return factory(Subfleet::class)->create()->id; return factory(App\Models\Subfleet::class)->create()->id;
}, },
'airport_id' => function () { 'airport_id' => function () {
return factory(Airport::class)->create()->id; return factory(App\Models\Airport::class)->create()->id;
}, },
'iata' => $faker->unique()->text(5), 'iata' => $faker->unique()->text(5),
'icao' => $faker->unique()->text(5), 'icao' => $faker->unique()->text(5),
'name' => $faker->text(50), 'name' => $faker->text(50),
'registration' => $faker->unique()->text(10), 'registration' => $faker->unique()->text(10),
'hex_code' => ICAO::createHexCode(), 'hex_code' => \App\Support\ICAO::createHexCode(),
'mtow' => $faker->randomFloat(2, 0, 50000),
'zfw' => $faker->randomFloat(2, 0, 50000), 'zfw' => $faker->randomFloat(2, 0, 50000),
'status' => AircraftStatus::ACTIVE, 'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
'state' => AircraftState::PARKED, 'state' => \App\Models\Enums\AircraftState::PARKED,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'), 'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $pirep) { 'updated_at' => function (array $pirep) {
return $pirep['created_at']; return $pirep['created_at'];
+1 -1
View File
@@ -9,7 +9,7 @@ use Hashids\Hashids;
$factory->define(App\Models\Airline::class, function (Faker $faker) { $factory->define(App\Models\Airline::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'icao' => function (array $apt) { 'icao' => function (array $apt) use ($faker) {
$hashids = new Hashids(microtime(), 5); $hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true)); $mt = str_replace('.', '', microtime(true));
+4 -4
View File
@@ -8,19 +8,19 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->numberBetween(10, 10000000), 'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () { 'airline_id' => function () {
return factory(\App\Models\Airline::class)->create()->id; return factory(App\Models\Airline::class)->create()->id;
}, },
'flight_number' => $faker->unique()->numberBetween(10, 1000000), 'flight_number' => $faker->unique()->numberBetween(10, 1000000),
'route_code' => $faker->randomElement(['', $faker->text(5)]), 'route_code' => $faker->randomElement(['', $faker->text(5)]),
'route_leg' => $faker->randomElement(['', $faker->numberBetween(0, 1000)]), 'route_leg' => $faker->randomElement(['', $faker->numberBetween(0, 1000)]),
'dpt_airport_id' => function () { 'dpt_airport_id' => function () {
return factory(\App\Models\Airport::class)->create()->id; return factory(App\Models\Airport::class)->create()->id;
}, },
'arr_airport_id' => function () { 'arr_airport_id' => function () {
return factory(\App\Models\Airport::class)->create()->id; return factory(App\Models\Airport::class)->create()->id;
}, },
'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(1, 1000), 'distance' => $faker->numberBetween(1, 1000),
'route' => null, 'route' => null,
@@ -1,20 +1,17 @@
<?php <?php
use App\Models\Journal;
use Carbon\Carbon;
use Faker\Generator as Faker; use Faker\Generator as Faker;
use Ramsey\Uuid\Uuid;
$factory->define(App\Models\JournalTransaction::class, function (Faker $faker) { $factory->define(App\Models\JournalTransactions::class, function (Faker $faker) {
return [ return [
'transaction_group' => Uuid::uuid4()->toString(), 'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
'journal_id' => function () { 'journal_id' => function () {
return factory(Journal::class)->create()->id; return factory(App\Models\Journal::class)->create()->id;
}, },
'credit' => $faker->numberBetween(100, 10000), 'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000), 'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD', 'currency' => 'USD',
'memo' => $faker->sentence(6), 'memo' => $faker->sentence(6),
'post_date' => Carbon::now('UTC'), 'post_date' => \Carbon\Carbon::now(),
]; ];
}); });
+1 -1
View File
@@ -6,7 +6,7 @@ $factory->define(App\Models\News::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'user_id' => function () { 'user_id' => function () {
return factory(\App\Models\User::class)->create()->id; return factory(App\Models\User::class)->create()->id;
}, },
'subject' => $faker->text(), 'subject' => $faker->text(),
'body' => $faker->sentence, 'body' => $faker->sentence,
+4 -4
View File
@@ -10,8 +10,8 @@ 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(); $airline = factory(App\Models\Airline::class)->create();
$flight = factory(\App\Models\Flight::class)->create([ $flight = factory(App\Models\Flight::class)->create([
'airline_id' => $airline->id, 'airline_id' => $airline->id,
]); ]);
@@ -21,10 +21,10 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
return $airline->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;
}, },
'aircraft_id' => function () { 'aircraft_id' => function () {
return factory(\App\Models\Aircraft::class)->create()->id; return factory(App\Models\Aircraft::class)->create()->id;
}, },
'flight_id' => function () use ($flight) { 'flight_id' => function () use ($flight) {
return $flight->id; return $flight->id;
-13
View File
@@ -1,13 +0,0 @@
<?php
use Faker\Generator as Faker;
$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(),
];
});
+1 -1
View File
@@ -6,7 +6,7 @@ $factory->define(App\Models\Subfleet::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'airline_id' => function () { 'airline_id' => function () {
return factory(\App\Models\Airline::class)->create()->id; return factory(App\Models\Airline::class)->create()->id;
}, },
'name' => $faker->unique()->text(50), 'name' => $faker->unique()->text(50),
'type' => $faker->unique()->text(7), 'type' => $faker->unique()->text(7),
+1 -3
View File
@@ -1,9 +1,7 @@
<?php <?php
use App\Models\Airline;
use App\Models\Enums\UserState; use App\Models\Enums\UserState;
use Faker\Generator as Faker; use Faker\Generator as Faker;
use Illuminate\Support\Facades\Hash;
$factory->define(App\Models\User::class, function (Faker $faker) { $factory->define(App\Models\User::class, function (Faker $faker) {
static $password; static $password;
@@ -16,7 +14,7 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
'password' => $password ?: $password = Hash::make('secret'), 'password' => $password ?: $password = Hash::make('secret'),
'api_key' => $faker->sha1, 'api_key' => $faker->sha1,
'airline_id' => function () { 'airline_id' => function () {
return factory(Airline::class)->create()->id; return factory(App\Models\Airline::class)->create()->id;
}, },
'rank_id' => 1, 'rank_id' => 1,
'flights' => $faker->numberBetween(0, 1000), 'flights' => $faker->numberBetween(0, 1000),
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
class RolesPermissionsTables extends Migration class RolesPermissionsTables extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
// Create table for storing roles // Create table for storing roles
@@ -74,6 +79,11 @@ class RolesPermissionsTables extends Migration
$this->addData('roles', $roles); $this->addData('roles', $roles);
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('permission_user'); Schema::dropIfExists('permission_user');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration class CreatePasswordResetsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('password_resets', function (Blueprint $table) { Schema::create('password_resets', function (Blueprint $table) {
@@ -15,6 +20,11 @@ class CreatePasswordResetsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('password_resets'); Schema::dropIfExists('password_resets');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateSessionsTable extends Migration class CreateSessionsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('sessions', function (Blueprint $table) { Schema::create('sessions', function (Blueprint $table) {
@@ -18,6 +23,11 @@ class CreateSessionsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('sessions'); Schema::dropIfExists('sessions');
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
class CreateAirlinesTable extends Migration class CreateAirlinesTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('airlines', function (Blueprint $table) { Schema::create('airlines', function (Blueprint $table) {
@@ -27,6 +32,11 @@ class CreateAirlinesTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('airlines'); Schema::dropIfExists('airlines');
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
class CreateFaresTable extends Migration class CreateFaresTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('fares', function (Blueprint $table) { Schema::create('fares', function (Blueprint $table) {
@@ -20,6 +25,11 @@ class CreateFaresTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('fares'); Schema::dropIfExists('fares');
@@ -7,6 +7,11 @@ use Illuminate\Database\Schema\Blueprint;
class CreateFlightTables extends Migration class CreateFlightTables extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('flights', function (Blueprint $table) { Schema::create('flights', function (Blueprint $table) {
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
class CreateRanksTable extends Migration class CreateRanksTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('ranks', function (Blueprint $table) { Schema::create('ranks', function (Blueprint $table) {
@@ -25,6 +30,11 @@ class CreateRanksTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('ranks'); Schema::dropIfExists('ranks');
@@ -3,6 +3,9 @@
use App\Contracts\Migration; use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/**
* Class CreateSubfleetTables
*/
class CreateSubfleetTables extends Migration class CreateSubfleetTables extends Migration
{ {
public function up() public function up()
@@ -45,6 +48,11 @@ class CreateSubfleetTables extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('subfleets'); Schema::dropIfExists('subfleets');
@@ -7,6 +7,11 @@ use Illuminate\Support\Facades\Schema;
class CreateBidsTable extends Migration class CreateBidsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('bids', function (Blueprint $table) { Schema::create('bids', function (Blueprint $table) {
@@ -20,6 +25,11 @@ class CreateBidsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('bids'); Schema::dropIfExists('bids');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration class CreateJobsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('jobs', function (Blueprint $table) { Schema::create('jobs', function (Blueprint $table) {
@@ -19,6 +24,11 @@ class CreateJobsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('jobs'); Schema::dropIfExists('jobs');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration class CreateFailedJobsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('failed_jobs', function (Blueprint $table) { Schema::create('failed_jobs', function (Blueprint $table) {
@@ -18,6 +23,11 @@ class CreateFailedJobsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateNavdataTables extends Migration class CreateNavdataTables extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
/* /*
@@ -26,6 +31,11 @@ class CreateNavdataTables extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('navdata'); Schema::dropIfExists('navdata');
@@ -7,6 +7,11 @@ use Illuminate\Support\Facades\Schema;
class CreateAcarsTables extends Migration class CreateAcarsTables extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('acars', function (Blueprint $table) { Schema::create('acars', function (Blueprint $table) {
@@ -39,6 +44,11 @@ class CreateAcarsTables extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('acars'); Schema::dropIfExists('acars');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateStatsTable extends Migration class CreateStatsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('stats', function (Blueprint $table) { Schema::create('stats', function (Blueprint $table) {
@@ -20,6 +25,11 @@ class CreateStatsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('stats'); Schema::dropIfExists('stats');
@@ -17,6 +17,11 @@ class CreateNewsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::drop('news'); Schema::drop('news');
@@ -3,10 +3,14 @@
use App\Contracts\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;
use Modules\Awards\Awards\PilotFlightAwards;
class CreateAwardsTable extends Migration class CreateAwardsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('awards', function (Blueprint $table) { Schema::create('awards', function (Blueprint $table) {
@@ -19,6 +23,7 @@ class CreateAwardsTable extends Migration
// EG, the airports has an internal expense for gate costs // EG, the airports has an internal expense for gate costs
$table->string('ref_model')->nullable(); $table->string('ref_model')->nullable();
$table->text('ref_model_params')->nullable(); $table->text('ref_model_params')->nullable();
//$table->string('ref_model_id', 36)->nullable();
$table->timestamps(); $table->timestamps();
@@ -33,20 +38,13 @@ class CreateAwardsTable extends Migration
$table->index(['user_id', 'award_id']); $table->index(['user_id', 'award_id']);
}); });
/**
* Add a default, sample award
*/
$award = [
'name' => 'Pilot 50 flights',
'description' => 'When a pilot has 50 flights, give this award',
'ref_model' => PilotFlightAwards::class,
'ref_model_params' => 50,
];
$this->addAward($award);
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('awards'); Schema::dropIfExists('awards');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateJournalTransactionsTable extends Migration class CreateJournalTransactionsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('journal_transactions', function (Blueprint $table) { Schema::create('journal_transactions', function (Blueprint $table) {
@@ -29,6 +34,11 @@ class CreateJournalTransactionsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('journal_transactions'); Schema::dropIfExists('journal_transactions');
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
class CreateJournalsTable extends Migration class CreateJournalsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('journals', function (Blueprint $table) { Schema::create('journals', function (Blueprint $table) {
@@ -19,6 +24,11 @@ class CreateJournalsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('journals'); Schema::dropIfExists('journals');
@@ -1,7 +1,6 @@
<?php <?php
use App\Contracts\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;
@@ -15,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', 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();
@@ -1,12 +1,17 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class AddReadonlyToRoles extends Migration class AddReadonlyToRoles extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up(): void public function up(): void
{ {
Schema::table('roles', static function (Blueprint $table) { Schema::table('roles', static function (Blueprint $table) {
@@ -19,6 +24,11 @@ class AddReadonlyToRoles extends Migration
->update(['read_only' => true]); ->update(['read_only' => true]);
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void public function down(): void
{ {
Schema::table('roles', static function (Blueprint $table) { Schema::table('roles', static function (Blueprint $table) {
@@ -1,19 +1,21 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* 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`
*/
class UsersAddPilotId extends Migration 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() public function up()
{ {
Schema::table('users', static function (Blueprint $table) { Schema::table('users', static function (Blueprint $table) {
@@ -27,6 +29,11 @@ class UsersAddPilotId extends Migration
DB::table('users')->update(['pilot_id' => DB::raw('`id`')]); DB::table('users')->update(['pilot_id' => DB::raw('`id`')]);
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::table('users', function (Blueprint $table) { Schema::table('users', function (Blueprint $table) {
@@ -1,11 +1,16 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration class CreateNotificationsTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('notifications', function (Blueprint $table) { Schema::create('notifications', function (Blueprint $table) {
@@ -18,6 +23,11 @@ class CreateNotificationsTable extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('notifications'); Schema::dropIfExists('notifications');
@@ -1,16 +1,18 @@
<?php <?php
use App\Contracts\Migration;
use App\Models\Enums\PirepState; use App\Models\Enums\PirepState;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Change the PIREP state column to be a TINYINT
*/
class PirepsChangeStateType extends Migration class PirepsChangeStateType extends Migration
{ {
/**
* Change the PIREP state column to be a TINYINT
*
* @return void
*/
public function up() public function up()
{ {
// Migrate the old rejected state // Migrate the old rejected state
@@ -23,4 +25,13 @@ class PirepsChangeStateType extends Migration
$table->unsignedSmallInteger('state')->change(); $table->unsignedSmallInteger('state')->change();
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
} }
@@ -5,15 +5,27 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Add a `flight_id` column to the PIREPs table
*/
class PirepsAddFlightId extends Migration class PirepsAddFlightId extends Migration
{ {
/**
* Add a `flight_id` column to the PIREPs table
*/
public function up() public function up()
{ {
Schema::table('pireps', function (Blueprint $table) { Schema::table('pireps', function (Blueprint $table) {
$table->string('flight_id', Model::ID_MAX_LENGTH)->nullable()->after('aircraft_id'); $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');
});
}
} }
@@ -4,11 +4,11 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Add a `flight_type` column to the expenses table
*/
class ExpensesAddFlightType extends Migration class ExpensesAddFlightType extends Migration
{ {
/**
* Add a `flight_type` column to the expenses table
*/
public function up() public function up()
{ {
Schema::table('expenses', function (Blueprint $table) { Schema::table('expenses', function (Blueprint $table) {
@@ -18,6 +18,11 @@ class ExpensesAddFlightType extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::table('expenses', function (Blueprint $table) { Schema::table('expenses', function (Blueprint $table) {
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/** /**
@@ -25,4 +25,13 @@ class ModifyAirportsCoordinates extends Migration
$table->decimal('lon', 11, 5)->change()->default(0.0)->nullable(); $table->decimal('lon', 11, 5)->change()->default(0.0)->nullable();
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
} }
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/** /**
@@ -8,10 +8,24 @@ use Illuminate\Support\Facades\Schema;
*/ */
class FlightFieldNullable extends Migration class FlightFieldNullable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::table('flight_field_values', function ($table) { Schema::table('flight_field_values', function ($table) {
$table->text('value')->change()->nullable(); $table->text('value')->change()->nullable();
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
} }
@@ -1,14 +1,14 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Add a `load_factor` and `load_factor_variance` columns to the expenses table
*/
class FlightsAddLoadFactor extends Migration class FlightsAddLoadFactor extends Migration
{ {
/**
* Add a `load_factor` and `load_factor_variance` columns to the expenses table
*/
public function up() public function up()
{ {
Schema::table('flights', function (Blueprint $table) { Schema::table('flights', function (Blueprint $table) {
@@ -22,6 +22,11 @@ class FlightsAddLoadFactor extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::table('flights', function (Blueprint $table) { Schema::table('flights', function (Blueprint $table) {
@@ -1,14 +1,14 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
*/
class FlightsAddPilotPay extends Migration class FlightsAddPilotPay extends Migration
{ {
/**
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
*/
public function up() public function up()
{ {
Schema::table('flights', function (Blueprint $table) { Schema::table('flights', function (Blueprint $table) {
@@ -18,6 +18,11 @@ class FlightsAddPilotPay extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::table('flights', function (Blueprint $table) { Schema::table('flights', function (Blueprint $table) {
@@ -1,15 +1,15 @@
<?php <?php
use App\Contracts\Migration;
use App\Models\Enums\FareType; use App\Models\Enums\FareType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/**
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
*/
class FaresAddType extends Migration class FaresAddType extends Migration
{ {
/**
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
*/
public function up() public function up()
{ {
Schema::table('fares', function (Blueprint $table) { Schema::table('fares', function (Blueprint $table) {
@@ -19,4 +19,16 @@ class FaresAddType extends Migration
->after('capacity'); ->after('capacity');
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('fares', function (Blueprint $table) {
$table->dropColumn('type');
});
}
} }
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -33,4 +33,13 @@ class IncreaseIdLengths extends Migration
}); });
} }
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
} }
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -15,4 +15,13 @@ class RemoveSubfleetTypeIndex extends Migration
$table->dropUnique(['type']); $table->dropUnique(['type']);
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
} }
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -1,7 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use App\Models\Enums\PageType;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -11,6 +10,11 @@ use Illuminate\Support\Facades\Schema;
*/ */
class CreatePages extends Migration class CreatePages extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('pages', function (Blueprint $table) { Schema::create('pages', function (Blueprint $table) {
@@ -18,7 +22,7 @@ class CreatePages extends Migration
$table->string('name'); $table->string('name');
$table->string('slug'); $table->string('slug');
$table->string('icon'); $table->string('icon');
$table->unsignedSmallInteger('type')->default(PageType::PAGE); $table->unsignedSmallInteger('type');
$table->boolean('public'); $table->boolean('public');
$table->boolean('enabled'); $table->boolean('enabled');
$table->mediumText('body'); $table->mediumText('body');
@@ -28,6 +32,11 @@ class CreatePages extends Migration
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('pages'); Schema::dropIfExists('pages');
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -9,7 +9,11 @@ class AirlineRemoveNullable extends Migration
public function up() public function up()
{ {
Schema::table('airlines', function (Blueprint $table) { Schema::table('airlines', function (Blueprint $table) {
$table->dropUnique(['iata']); $table->dropUnique('airlines_iata_unique');
}); });
} }
public function down()
{
}
} }
@@ -1,6 +1,6 @@
<?php <?php
use App\Contracts\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -12,4 +12,8 @@ class PageIconNullable extends Migration
$table->string('icon')->change()->nullable(); $table->string('icon')->change()->nullable();
}); });
} }
public function down()
{
}
} }
@@ -1,33 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a `link` column and make the body optional. Also add a "new_window" bool
* which determines if we open this link in a new window or not
*/
class PagesAddLink extends Migration
{
public function up()
{
Schema::table('pages', function (Blueprint $table) {
$table->string('body')->change()->nullable();
$table->string('link')
->default('')
->nullable()
->after('body');
$table->boolean('new_window')->default(false);
});
}
public function down()
{
Schema::table('fares', function (Blueprint $table) {
$table->dropColumn('link');
$table->dropColumn('new_window');
});
}
}
@@ -1,42 +0,0 @@
<?php
use App\Contracts\Model;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add two tables for holding user fields and the values
*/
class CreateUserFields extends Migration
{
public function up()
{
/*
* Hold a master list of fields
*/
Schema::create('user_fields', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 200);
$table->text('description')->nullable();
$table->boolean('show_on_registration')->default(false)->nullable();
$table->boolean('required')->default(false)->nullable();
$table->boolean('private')->default(false)->nullable();
$table->boolean('active')->default(true)->nullable();
$table->timestamps();
});
/*
* The values for the actual fields
*/
Schema::create('user_field_values', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_field_id');
$table->string('user_id', Model::ID_MAX_LENGTH);
$table->text('value')->nullable();
$table->timestamps();
$table->index(['user_field_id', 'user_id']);
});
}
}
@@ -1,28 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a `mtow` column for the max takeoff weight
*/
class AircraftAddMtow extends Migration
{
public function up()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->unsignedDecimal('mtow')
->nullable()
->default(0.0)
->after('hex_code');
});
}
public function down()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->dropColumn('mtow');
});
}
}
@@ -1,29 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateModulesTable extends Migration
{
public function up()
{
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->boolean('enabled')->default(1);
$table->timestamps();
});
$this->addModule(['name' => 'Awards']);
$this->addModule(['name' => 'Sample']);
$this->addModule(['name' => 'VMSAcars']);
$this->addModule(['name' => 'Vacentral']);
$this->addModule(['name' => 'TestModule']);
}
public function down()
{
Schema::dropIfExists('modules');
}
}
@@ -1,18 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Change the pages body column type to a Medium Text, max size of 16MB
*/
class ModifyPagesSize extends Migration
{
public function up()
{
Schema::table('pages', function (Blueprint $table) {
$table->mediumText('body')->change()->nullable();
});
}
}
@@ -1,19 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Change the downloads link size
*/
class ModifyDownloadLinkSize extends Migration
{
public function up()
{
Schema::table('files', function (Blueprint $table) {
$table->mediumText('disk')->change()->nullable();
$table->mediumText('path')->change()->nullable();
});
}
}
@@ -1,20 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a hub to the subfleet is
*/
class AddHubToSubfleets extends Migration
{
public function up()
{
Schema::table('subfleets', function (Blueprint $table) {
$table->string('hub_id', 4)
->nullable()
->after('airline_id');
});
}
}
@@ -1,18 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Change the vertical speed for the acars table to a double
*/
class ChangeAcarsVsType extends Migration
{
public function up()
{
Schema::table('acars', function (Blueprint $table) {
$table->float('vs')->change()->default(0.0)->nullable();
});
}
}
@@ -1,19 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Bring the sessions table in line with the latest
*/
class UpdateSessionsTable extends Migration
{
public function up()
{
Schema::table('sessions', function (Blueprint $table) {
$table->index('user_id');
$table->index('last_activity');
});
}
}
@@ -1,21 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a `fuel_onboard` column for recording what is left in tanks
*/
class AircraftAddFuelonboard extends Migration
{
public function up()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->unsignedDecimal('fuel_onboard')
->nullable()
->default(0.0)
->after('zfw');
});
}
}
@@ -1,20 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a SimBrief Type to subfleet
*/
class AddSbtypeToSubfleets extends Migration
{
public function up()
{
Schema::table('subfleets', function (Blueprint $table) {
$table->string('simbrief_type', 20)
->nullable()
->after('type');
});
}
}
@@ -1,24 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a hub to the subfleet is
*/
class AddAircraftToSimbrief extends Migration
{
public function up()
{
Schema::table('simbrief', function (Blueprint $table) {
$table->unsignedInteger('aircraft_id')
->nullable()
->after('pirep_id');
// Temp column to hold the calculated fare data for the API
// Remove this once the prefile to acars feature is completed
$table->mediumText('fare_data')->nullable()->after('ofp_xml');
});
}
}
@@ -1,19 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a hub to the subfleet is
*/
class AddKvpTable extends Migration
{
public function up()
{
Schema::create('kvp', function (Blueprint $table) {
$table->string('key')->index();
$table->string('value');
});
}
}
@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDisableactivitychecksToRoles extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('roles', function (Blueprint $table) {
$table->boolean('disable_activity_checks')
->default(false)
->after('read_only');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('disable_activity_checks');
});
}
}
@@ -1,19 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class RemoveSettingRemoveBidOnAccept extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('settings')
->where(['key' => 'pireps.remove_bid_on_accept'])
->delete();
}
}

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