Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa8cda89d6 | ||
|
|
5ba65cf2d1 |
@@ -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
|
||||
@@ -1,252 +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 self-update --1
|
||||
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 self-update --1
|
||||
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 self-update --1
|
||||
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 }}'
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
#
|
||||
# Travis CI config file
|
||||
#
|
||||
|
||||
language: php
|
||||
php:
|
||||
- '7.4'
|
||||
- '7.3'
|
||||
|
||||
#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'
|
||||
Regular → Executable
+71
-7
@@ -1,12 +1,52 @@
|
||||
#!/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 "Full Version: ${FULL_VERSION}"
|
||||
echo "Package name: ${TAR_NAME}"
|
||||
echo "Current directory: ${BASE_DIR}"
|
||||
|
||||
echo "==========================="
|
||||
|
||||
echo "Cleaning files"
|
||||
|
||||
rm -rf vendor
|
||||
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||
|
||||
# Leftover individual files to delete
|
||||
declare -a remove_files=(
|
||||
.git
|
||||
@@ -67,20 +107,44 @@ 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
|
||||
|
||||
cd /tmp
|
||||
ls -al $TRAVIS_BUILD_DIR/../
|
||||
|
||||
ls -al $BASE_DIR/../
|
||||
|
||||
tar -czf $TAR_NAME -C $BASE_DIR .
|
||||
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR .
|
||||
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
||||
tar2zip $TAR_NAME
|
||||
sha256sum $ZIP_NAME >"$ZIP_NAME.sha256"
|
||||
|
||||
ls -al /tmp
|
||||
|
||||
echo "Moving to dist"
|
||||
mkdir -p $BASE_DIR/dist
|
||||
cd $BASE_DIR/dist
|
||||
echo "Uploading to S3"
|
||||
mkdir -p $TRAVIS_BUILD_DIR/build
|
||||
cd $TRAVIS_BUILD_DIR/build
|
||||
|
||||
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,15 +1,18 @@
|
||||
# phpVMS <sup>7</sup>
|
||||
# phpvms <sup>7</sup>
|
||||
|
||||
[](https://github.com/nabeelio/phpvms/actions) [](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&utm_medium=referral&utm_content=nabeelio/phpvms&utm_campaign=Badge_Grade) [](https://packagist.org/packages/nabeel/phpvms)  [](https://packagist.org/packages/nabeel/phpvms)
|
||||
[](https://travis-ci.org/nabeelio/phpvms) [](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&utm_medium=referral&utm_content=nabeelio/phpvms&utm_campaign=Badge_Grade) [](https://packagist.org/packages/nabeel/phpvms)  [](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
|
||||
[GitHub Releases](https://github.com/nabeelio/phpvms/releases) link.
|
||||
|
||||
### Requirements
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 7.3+, extensions:
|
||||
- cURL
|
||||
@@ -21,16 +24,16 @@ A full distribution, with all of the composer dependencies, is available at this
|
||||
- Database:
|
||||
- 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. 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:
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
### Building JS/CSS assets
|
||||
## Building JS/CSS assets
|
||||
|
||||
Yarn is required, run:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Contracts\Command;
|
||||
use App\Services\Installer\ConfigService;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
|
||||
/**
|
||||
* Create a fresh development install
|
||||
|
||||
+5
-49
@@ -12,24 +12,13 @@ abstract class Metar
|
||||
{
|
||||
/**
|
||||
* 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,
|
||||
* return a blank string
|
||||
* since this shouldn't be directly called. Call `get_metar($icao)` instead
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function get_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;
|
||||
abstract protected function metar($icao): string;
|
||||
|
||||
/**
|
||||
* Download the METAR, wrap in caching
|
||||
@@ -38,9 +27,9 @@ abstract class Metar
|
||||
*
|
||||
* @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;
|
||||
|
||||
if (Cache::has($key)) {
|
||||
@@ -51,7 +40,7 @@ abstract class Metar
|
||||
}
|
||||
|
||||
try {
|
||||
$raw_metar = $this->get_metar($icao);
|
||||
$raw_metar = $this->metar($icao);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
||||
return '';
|
||||
@@ -63,37 +52,4 @@ abstract class 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Models\Module;
|
||||
use App\Support\Database;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Determine if any pilots should be set to ON LEAVE status
|
||||
@@ -16,8 +18,6 @@ class PilotLeave extends Listener
|
||||
|
||||
/**
|
||||
* PilotLeave constructor.
|
||||
*
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(UserService $userSvc)
|
||||
{
|
||||
@@ -34,7 +34,14 @@ class PilotLeave extends Listener
|
||||
*/
|
||||
public function handle(CronNightly $event): void
|
||||
{
|
||||
$users = $this->userSvc->findUsersOnLeave();
|
||||
if (setting('pilots.auto_leave_days') === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
|
||||
$users = User::where('status', UserState::ACTIVE)
|
||||
->whereDate('updated_at', '<', $date);
|
||||
|
||||
foreach ($users as $user) {
|
||||
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
||||
$this->userSvc->setStatusOnLeave($user);
|
||||
|
||||
@@ -42,18 +42,23 @@ class SetActiveFlights extends Listener
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set to visible by default
|
||||
$flight->visible = true;
|
||||
|
||||
// dates aren't set, so just save if there were any changes above
|
||||
// and move onto the next one
|
||||
if ($flight->start_date === null || $flight->end_date === null) {
|
||||
if ($flight->days !== null && $flight->days > 0) {
|
||||
$flight->visible = Days::isToday($flight->days);
|
||||
if (!$flight->visible) {
|
||||
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
|
||||
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
|
||||
$visible = Days::isToday($flight->days);
|
||||
if ($flight->visible !== $visible) {
|
||||
Log::info('Flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden'));
|
||||
|
||||
$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();
|
||||
@@ -66,11 +71,20 @@ class SetActiveFlights extends Listener
|
||||
// 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 ($flight->days !== null && $flight->days > 0) {
|
||||
$flight->visible = Days::isToday($flight->days);
|
||||
if (!$flight->visible) {
|
||||
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
|
||||
$visible = Days::isToday($flight->days);
|
||||
if ($flight->visible !== $visible) {
|
||||
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')]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log::info('Toggling flight '.$flight->ident.' to visible');
|
||||
$flight->visible = true;
|
||||
}
|
||||
} else {
|
||||
$flight->visible = false;
|
||||
|
||||
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class RolesPermissionsTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Create table for storing roles
|
||||
@@ -74,6 +79,11 @@ class RolesPermissionsTables extends Migration
|
||||
$this->addData('roles', $roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('permission_user');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
@@ -15,6 +20,11 @@ class CreatePasswordResetsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSessionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
@@ -18,6 +23,11 @@ class CreateSessionsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
|
||||
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAirlinesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('airlines', function (Blueprint $table) {
|
||||
@@ -27,6 +32,11 @@ class CreateAirlinesTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('airlines');
|
||||
|
||||
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFaresTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('fares', function (Blueprint $table) {
|
||||
@@ -20,6 +25,11 @@ class CreateFaresTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('fares');
|
||||
|
||||
@@ -7,6 +7,11 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFlightTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('flights', function (Blueprint $table) {
|
||||
|
||||
@@ -5,6 +5,11 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateRanksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('ranks', function (Blueprint $table) {
|
||||
@@ -25,6 +30,11 @@ class CreateRanksTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('ranks');
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateSubfleetTables
|
||||
*/
|
||||
class CreateSubfleetTables extends Migration
|
||||
{
|
||||
public function up()
|
||||
@@ -45,6 +48,11 @@ class CreateSubfleetTables extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('subfleets');
|
||||
|
||||
@@ -7,6 +7,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBidsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bids', function (Blueprint $table) {
|
||||
@@ -20,6 +25,11 @@ class CreateBidsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bids');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
@@ -19,6 +24,11 @@ class CreateJobsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
@@ -18,6 +23,11 @@ class CreateFailedJobsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNavdataTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
@@ -26,6 +31,11 @@ class CreateNavdataTables extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('navdata');
|
||||
|
||||
@@ -7,6 +7,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAcarsTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('acars', function (Blueprint $table) {
|
||||
@@ -39,6 +44,11 @@ class CreateAcarsTables extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('acars');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateStatsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('stats', function (Blueprint $table) {
|
||||
@@ -20,6 +25,11 @@ class CreateStatsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('stats');
|
||||
|
||||
@@ -17,6 +17,11 @@ class CreateNewsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('news');
|
||||
|
||||
@@ -7,6 +7,13 @@ use Modules\Awards\Awards\PilotFlightAwards;
|
||||
|
||||
class CreateAwardsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('awards', function (Blueprint $table) {
|
||||
@@ -47,6 +54,11 @@ class CreateAwardsTable extends Migration
|
||||
$this->addAward($award);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('awards');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJournalTransactionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('journal_transactions', function (Blueprint $table) {
|
||||
@@ -29,6 +34,11 @@ class CreateJournalTransactionsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('journal_transactions');
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJournalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('journals', function (Blueprint $table) {
|
||||
@@ -19,6 +24,11 @@ class CreateJournalsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('journals');
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use App\Contracts\Model;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -15,7 +14,7 @@ class CreateFilesTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
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('description')->nullable();
|
||||
$table->string('disk')->nullable();
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
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) {
|
||||
@@ -19,6 +24,11 @@ class AddReadonlyToRoles extends Migration
|
||||
->update(['read_only' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('roles', static function (Blueprint $table) {
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* 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', static function (Blueprint $table) {
|
||||
@@ -27,6 +29,11 @@ class UsersAddPilotId extends Migration
|
||||
DB::table('users')->update(['pilot_id' => DB::raw('`id`')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
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) {
|
||||
@@ -18,6 +23,11 @@ class CreateNotificationsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Change the PIREP state column to be a TINYINT
|
||||
*/
|
||||
class PirepsChangeStateType extends Migration
|
||||
{
|
||||
/**
|
||||
* Change the PIREP state column to be a TINYINT
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Migrate the old rejected state
|
||||
@@ -23,4 +25,13 @@ class PirepsChangeStateType extends Migration
|
||||
$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\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Add a `flight_id` column to the PIREPs table
|
||||
*/
|
||||
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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Add a `flight_type` column to the expenses table
|
||||
*/
|
||||
class ExpensesAddFlightType extends Migration
|
||||
{
|
||||
/**
|
||||
* Add a `flight_type` column to the expenses table
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('expenses', function (Blueprint $table) {
|
||||
@@ -18,6 +18,11 @@ class ExpensesAddFlightType extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('expenses', function (Blueprint $table) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
@@ -25,4 +25,13 @@ class ModifyAirportsCoordinates extends Migration
|
||||
$table->decimal('lon', 11, 5)->change()->default(0.0)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
@@ -8,10 +8,24 @@ use Illuminate\Support\Facades\Schema;
|
||||
*/
|
||||
class FlightFieldNullable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('flight_field_values', function ($table) {
|
||||
$table->text('value')->change()->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Add a `load_factor` and `load_factor_variance` columns to the expenses table
|
||||
*/
|
||||
class FlightsAddLoadFactor extends Migration
|
||||
{
|
||||
/**
|
||||
* Add a `load_factor` and `load_factor_variance` columns to the expenses table
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
@@ -22,6 +22,11 @@ class FlightsAddLoadFactor extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
@@ -18,6 +18,11 @@ class FlightsAddPilotPay extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use App\Models\Enums\FareType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('fares', function (Blueprint $table) {
|
||||
@@ -19,4 +19,16 @@ class FaresAddType extends Migration
|
||||
->after('capacity');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('fares', function (Blueprint $table) {
|
||||
$table->dropColumn('type');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
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
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -15,4 +15,13 @@ class RemoveSubfleetTypeIndex extends Migration
|
||||
$table->dropUnique(['type']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use App\Models\Enums\PageType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -11,6 +11,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
*/
|
||||
class CreatePages extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('pages', function (Blueprint $table) {
|
||||
@@ -28,6 +33,11 @@ class CreatePages extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('pages');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -9,7 +9,11 @@ class AirlineRemoveNullable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::table('airlines', function (Blueprint $table) {
|
||||
$table->dropUnique(['iata']);
|
||||
$table->dropUnique('airlines_iata_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -12,4 +12,8 @@ class PageIconNullable extends Migration
|
||||
$table->string('icon')->change()->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\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
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('pages', function (Blueprint $table) {
|
||||
@@ -23,6 +23,9 @@ class PagesAddLink extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('fares', function (Blueprint $table) {
|
||||
|
||||
@@ -5,11 +5,11 @@ 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
|
||||
{
|
||||
/**
|
||||
* Add two tables for holding user fields and the values
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
@@ -39,4 +39,11 @@ class CreateUserFields extends Migration
|
||||
$table->index(['user_field_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -19,6 +19,11 @@ class AircraftAddMtow extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('aircraft', function (Blueprint $table) {
|
||||
|
||||
@@ -6,6 +6,11 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateModulesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('modules', function (Blueprint $table) {
|
||||
@@ -22,6 +27,11 @@ class CreateModulesTable extends Migration
|
||||
$this->addModule(['name' => 'TestModule']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('modules');
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyPirepFares extends Migration
|
||||
{
|
||||
/**
|
||||
* Modify the PIREP fares table so that we can save all of the fares for that particular PIREP
|
||||
* Basically copy all of those fields over, and then use this table directly, instead of the
|
||||
* relationship to the fares table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
* Add the columns we need from the fares table so then this is now "fixed" in time
|
||||
*/
|
||||
Schema::table('pirep_fares', function (Blueprint $table) {
|
||||
$table->unsignedInteger('fare_id')->change()->nullable()->default(0);
|
||||
|
||||
$table->string('code', 50);
|
||||
$table->string('name', 50);
|
||||
|
||||
// count is already there
|
||||
|
||||
$table->unsignedDecimal('price')->nullable()->default(0.00);
|
||||
$table->unsignedDecimal('cost')->nullable()->default(0.00);
|
||||
$table->unsignedInteger('capacity')->nullable()->default(0);
|
||||
});
|
||||
|
||||
/**
|
||||
* Now iterate through the existing table and copy/update everything
|
||||
* Some fares might already have been removed deleted so just insert some null/errored
|
||||
* values for those
|
||||
*/
|
||||
$parent_fares = [];
|
||||
$fares = DB::table('pirep_fares')->get();
|
||||
foreach ($fares as $fare) {
|
||||
if (empty($parent_fares[$fare->fare_id])) {
|
||||
$parent_fares[$fare->fare_id] = DB::table('fares')->where('id', $fare->fare_id)->first();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class ValidationException extends AbstractHttpException
|
||||
|
||||
parent::__construct(
|
||||
400,
|
||||
'Validation Error'
|
||||
'Validation exception'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,6 @@ class AircraftController extends Controller
|
||||
*/
|
||||
public function update($id, UpdateAircraftRequest $request)
|
||||
{
|
||||
/** @var \App\Models\Aircraft $aircraft */
|
||||
$aircraft = $this->aircraftRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($aircraft)) {
|
||||
@@ -172,7 +171,7 @@ class AircraftController extends Controller
|
||||
$this->aircraftRepo->update($attrs, $id);
|
||||
|
||||
Flash::success('Aircraft updated successfully.');
|
||||
return redirect(route('admin.aircraft.index').'?subfleet='.$aircraft->subfleet_id);
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +183,6 @@ class AircraftController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
/** @var \App\Models\Aircraft $aircraft */
|
||||
$aircraft = $this->aircraftRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($aircraft)) {
|
||||
|
||||
@@ -186,13 +186,13 @@ class AwardController extends Controller
|
||||
{
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Award not found');
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
$this->awardRepository->delete($id);
|
||||
Flash::success('Award deleted successfully.');
|
||||
Flash::success('Fare deleted successfully.');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Http\Controllers\Admin\Traits\Importable;
|
||||
use App\Http\Requests\CreateSubfleetRequest;
|
||||
use App\Http\Requests\UpdateSubfleetRequest;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Airport;
|
||||
use App\Models\Enums\FareType;
|
||||
use App\Models\Enums\FuelType;
|
||||
use App\Models\Enums\ImportExportType;
|
||||
@@ -134,7 +133,6 @@ class SubfleetController extends Controller
|
||||
{
|
||||
return view('admin.subfleets.create', [
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'hubs' => Airport::where('hub', 1)->pluck('name', 'id'),
|
||||
'fuel_types' => FuelType::labels(),
|
||||
]);
|
||||
}
|
||||
@@ -205,7 +203,6 @@ class SubfleetController extends Controller
|
||||
|
||||
return view('admin.subfleets.edit', [
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'hubs' => Airport::where('hub', 1)->pluck('name', 'id'),
|
||||
'fuel_types' => FuelType::labels(),
|
||||
'avail_fares' => $avail_fares,
|
||||
'avail_ranks' => $avail_ranks,
|
||||
|
||||
@@ -4,11 +4,9 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Exceptions\AssetNotFound;
|
||||
use App\Exceptions\Unauthorized;
|
||||
use App\Http\Resources\Flight as FlightResource;
|
||||
use App\Http\Resources\Navdata as NavdataResource;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FareService;
|
||||
@@ -154,25 +152,20 @@ class FlightController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function briefing(string $id)
|
||||
public function briefing($id)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$w = [
|
||||
'id' => $id,
|
||||
'user_id' => $user->id,
|
||||
'flight_id' => $id,
|
||||
];
|
||||
|
||||
/** @var SimBrief $simbrief */
|
||||
$simbrief = SimBrief::where($w)->first();
|
||||
|
||||
if ($simbrief === null) {
|
||||
throw new AssetNotFound(new Exception('Flight briefing not found'));
|
||||
}
|
||||
|
||||
/*if ($simbrief->user_id !== $user->id) {
|
||||
throw new Unauthorized(new Exception('User cannot access another user\'s simbrief'));
|
||||
}*/
|
||||
|
||||
return response($simbrief->acars_xml, 200, [
|
||||
'Content-Type' => 'application/xml',
|
||||
]);
|
||||
|
||||
@@ -22,6 +22,8 @@ use App\Models\Acars;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepFieldSource;
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\PirepComment;
|
||||
use App\Repositories\AcarsRepository;
|
||||
@@ -36,6 +38,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class PirepController
|
||||
*/
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $acarsRepo;
|
||||
@@ -88,10 +93,6 @@ class PirepController extends Controller
|
||||
$attrs['created_at'] = Carbon::createFromTimeString($attrs['created_at']);
|
||||
}
|
||||
|
||||
if (array_key_exists('submitted_at', $attrs)) {
|
||||
$attrs['submitted_at'] = Carbon::createFromTimeString($attrs['submitted_at']);
|
||||
}
|
||||
|
||||
if (array_key_exists('updated_at', $attrs)) {
|
||||
$attrs['updated_at'] = Carbon::createFromTimeString($attrs['updated_at']);
|
||||
}
|
||||
@@ -305,8 +306,14 @@ class PirepController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$attrs['state'] = PirepState::PENDING;
|
||||
$attrs['status'] = PirepStatus::ARRIVED;
|
||||
$attrs['submitted_at'] = Carbon::now('UTC');
|
||||
|
||||
$pirep = $this->pirepRepo->update($attrs, $pirep_id);
|
||||
|
||||
try {
|
||||
$pirep = $this->pirepSvc->file($pirep, $attrs);
|
||||
$pirep = $this->pirepSvc->create($pirep);
|
||||
$this->updateFields($pirep, $request);
|
||||
$this->updateFares($pirep, $request);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -42,14 +42,7 @@ class DownloadController extends Controller
|
||||
$category = explode('\\', $class);
|
||||
$category = end($category);
|
||||
|
||||
if ($category == 'Aircraft') {
|
||||
$group_name = $category.' > '.$obj->icao.' '.$obj->registration;
|
||||
} elseif ($category == 'Airport') {
|
||||
$group_name = $category.' > '.$obj->icao.' : '.$obj->name.' ('.$obj->country.')';
|
||||
} else {
|
||||
$group_name = $category.' > '.$obj->name;
|
||||
}
|
||||
|
||||
$group_name = $category.' - '.$obj->name;
|
||||
$regrouped_files[$group_name] = $files;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Models\Bid;
|
||||
use App\Models\Enums\FlightType;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
@@ -121,8 +120,6 @@ class FlightController extends Controller
|
||||
'saved' => $saved_flights,
|
||||
'subfleets' => $this->subfleetRepo->selectBoxList(true),
|
||||
'flight_number' => $request->input('flight_number'),
|
||||
'flight_types' => FlightType::select(true),
|
||||
'flight_type' => $request->input('flight_type'),
|
||||
'arr_icao' => $request->input('arr_icao'),
|
||||
'dep_icao' => $request->input('dep_icao'),
|
||||
'subfleet_id' => $request->input('subfleet_id'),
|
||||
@@ -147,12 +144,6 @@ class FlightController extends Controller
|
||||
$flights = collect();
|
||||
$saved_flights = [];
|
||||
foreach ($user->bids as $bid) {
|
||||
// Remove any invalid bids (flight doesn't exist or something)
|
||||
if (!$bid->flight) {
|
||||
$bid->delete();
|
||||
continue;
|
||||
}
|
||||
|
||||
$flights->add($bid->flight);
|
||||
$saved_flights[] = $bid->flight->id;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class ProfileController extends Controller
|
||||
{
|
||||
// Is the ACARS module enabled?
|
||||
$acars_enabled = false;
|
||||
$acars = Module::find('VMSAcars');
|
||||
$acars = Module::find('VMSACARS');
|
||||
if ($acars) {
|
||||
$acars_enabled = $acars->isEnabled();
|
||||
}
|
||||
@@ -95,7 +95,6 @@ class ProfileController extends Controller
|
||||
'user' => $user,
|
||||
'userFields' => $userFields,
|
||||
'airports' => $airports,
|
||||
'acars' => $this->acarsEnabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -122,7 +121,7 @@ class ProfileController extends Controller
|
||||
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
$userFields = $this->userRepo->getUserFields($user, true);
|
||||
$userFields = $this->userRepo->getUserFields($user, false);
|
||||
|
||||
return view('profile.edit', [
|
||||
'user' => $user,
|
||||
@@ -197,7 +196,6 @@ class ProfileController extends Controller
|
||||
});
|
||||
|
||||
$canvas->insert($image);
|
||||
Log::info('Uploading avatar into folder '.public_path('uploads/avatars'));
|
||||
$canvas->save(public_path('uploads/avatars/'.$file_name));
|
||||
|
||||
$req_data['avatar'] = $path;
|
||||
|
||||
@@ -3,34 +3,22 @@
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Exceptions\AssetNotFound;
|
||||
use App\Models\Aircraft;
|
||||
use App\Models\Enums\FlightType;
|
||||
use App\Models\SimBrief;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FareService;
|
||||
use App\Services\SimBriefService;
|
||||
use App\Services\UserService;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SimBriefController
|
||||
{
|
||||
private $fareSvc;
|
||||
private $flightRepo;
|
||||
private $simBriefSvc;
|
||||
private $userSvc;
|
||||
|
||||
public function __construct(
|
||||
FareService $fareSvc,
|
||||
FlightRepository $flightRepo,
|
||||
SimBriefService $simBriefSvc,
|
||||
UserService $userSvc
|
||||
) {
|
||||
$this->fareSvc = $fareSvc;
|
||||
public function __construct(FlightRepository $flightRepo, SimBriefService $simBriefSvc)
|
||||
{
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->simBriefSvc = $simBriefSvc;
|
||||
$this->userSvc = $userSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,14 +32,8 @@ class SimBriefController
|
||||
*/
|
||||
public function generate(Request $request)
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
$flight_id = $request->input('flight_id');
|
||||
$aircraft_id = $request->input('aircraft_id');
|
||||
$flight = $this->flightRepo->with(['subfleets'])->find($flight_id);
|
||||
$flight = $this->fareSvc->getReconciledFaresForFlight($flight);
|
||||
|
||||
$flight = $this->flightRepo->find($flight_id);
|
||||
if (!$flight) {
|
||||
flash()->error('Unknown flight');
|
||||
return redirect(route('frontend.flights.index'));
|
||||
@@ -63,7 +45,7 @@ class SimBriefController
|
||||
return redirect(route('frontend.flights.index'));
|
||||
}
|
||||
|
||||
// Check if a Simbrief profile already exists
|
||||
$user = Auth::user();
|
||||
$simbrief = SimBrief::select('id')->where([
|
||||
'flight_id' => $flight_id,
|
||||
'user_id' => $user->id,
|
||||
@@ -73,57 +55,8 @@ class SimBriefController
|
||||
return redirect(route('frontend.simbrief.briefing', [$simbrief->id]));
|
||||
}
|
||||
|
||||
// Simbrief Profile doesn't exist; prompt the user to create a new one
|
||||
$aircraft = Aircraft::select('registration', 'name', 'icao', 'iata', 'subfleet_id')
|
||||
->where('id', $aircraft_id)
|
||||
->get();
|
||||
|
||||
if ($flight->subfleets->count() > 0) {
|
||||
$subfleets = $flight->subfleets;
|
||||
} else {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
}
|
||||
|
||||
if ($flight->flight_type === FlightType::CHARTER_PAX_ONLY) {
|
||||
$pax_weight = 197;
|
||||
} else {
|
||||
$pax_weight = 208;
|
||||
}
|
||||
|
||||
// No aircraft selected, show that form
|
||||
if (!$aircraft_id) {
|
||||
return view('flights.simbrief_aircraft', [
|
||||
'flight' => $flight,
|
||||
'aircraft' => $aircraft,
|
||||
'subfleets' => $subfleets,
|
||||
'pax_weight' => $pax_weight,
|
||||
]);
|
||||
}
|
||||
|
||||
// Get the correct load factors
|
||||
$lfactor = $flight->load_factor ?? setting('flights.default_load_factor');
|
||||
$lfactorv = $flight->load_factor_variance ?? setting('flights.load_factor_variance');
|
||||
|
||||
$loadmin = $lfactor - $lfactorv;
|
||||
$loadmin = $loadmin < 0 ? 0 : $loadmin;
|
||||
|
||||
$loadmax = $lfactor + $lfactorv;
|
||||
$loadmax = $loadmax > 100 ? 100 : $loadmax;
|
||||
|
||||
// Failsafe for admins not defining load values for their flights
|
||||
// and also leave the general settings empty, set loadmax to 100
|
||||
if ($loadmax === 0) {
|
||||
$loadmax = 100;
|
||||
}
|
||||
|
||||
// Show the main simbrief form
|
||||
return view('flights.simbrief_form', [
|
||||
'flight' => $flight,
|
||||
'aircraft' => $aircraft,
|
||||
'subfleets' => $subfleets,
|
||||
'pax_weight' => $pax_weight,
|
||||
'loadmin' => $loadmin,
|
||||
'loadmax' => $loadmax,
|
||||
'flight' => $flight,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -142,53 +75,11 @@ class SimBriefController
|
||||
return redirect(route('frontend.flights.index'));
|
||||
}
|
||||
|
||||
$str = $simbrief->xml->aircraft->equip;
|
||||
$wc = stripos($str, '-');
|
||||
$tr = stripos($str, '/');
|
||||
$wakecat = substr($str, 0, $wc);
|
||||
$equipment = substr($str, $wc + 1, $tr - 2);
|
||||
$transponder = substr($str, $tr + 1);
|
||||
|
||||
return view('flights.simbrief_briefing', [
|
||||
'simbrief' => $simbrief,
|
||||
'wakecat' => $wakecat,
|
||||
'equipment' => $equipment,
|
||||
'transponder' => $transponder,
|
||||
'simbrief' => $simbrief,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the flight_id from the SimBrief Briefing (to a create a new one)
|
||||
* or if no pirep_id is attached to the briefing delete it completely
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function generate_new(Request $request)
|
||||
{
|
||||
$simbrief = SimBrief::find($request->id);
|
||||
|
||||
// Invalid Simbrief ID/profile, go back to the main flight index
|
||||
if (!$simbrief) {
|
||||
return redirect(route('frontend.flights.index'));
|
||||
}
|
||||
|
||||
// Cleanup the current Simbrief entry and redirect to the new generation form
|
||||
// If there isn't a PIREP ID, then delete the entry, otherwise, remove the flight
|
||||
$flight_id = $simbrief->flight_id;
|
||||
if (!$simbrief->pirep_id) {
|
||||
$simbrief->delete();
|
||||
} else {
|
||||
$simbrief->flight_id = null;
|
||||
$simbrief->save();
|
||||
}
|
||||
|
||||
return redirect(route('frontend.simbrief.generate').'?flight_id='.$flight_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a prefile of this PIREP with a given OFP. Then redirect the
|
||||
* user to the newly prefiled PIREP
|
||||
@@ -238,7 +129,7 @@ class SimBriefController
|
||||
$ofp_id = $request->input('ofp_id');
|
||||
$flight_id = $request->input('flight_id');
|
||||
|
||||
$simbrief = $this->simBriefSvc->downloadOfp(Auth::user()->id, $ofp_id, $flight_id);
|
||||
$simbrief = $this->simBriefSvc->checkForOfp(Auth::user()->id, $ofp_id, $flight_id);
|
||||
if ($simbrief === null) {
|
||||
$error = new AssetNotFound(new Exception('Simbrief OFP not found'));
|
||||
return $error->getResponse();
|
||||
|
||||
@@ -18,17 +18,17 @@ class Flight extends Resource
|
||||
private function setFields()
|
||||
{
|
||||
/** @var \Illuminate\Support\Collection $field_values */
|
||||
$return_values = new stdClass();
|
||||
$field_values = $this->field_values;
|
||||
if (empty($field_values) || $field_values->count() === 0) {
|
||||
return $return_values;
|
||||
return new stdClass();
|
||||
}
|
||||
|
||||
$fields = [];
|
||||
foreach ($field_values as $field) {
|
||||
$return_values->{$field->name} = $field->value;
|
||||
$fields[$field->name] = $field->value;
|
||||
}
|
||||
|
||||
return $return_values;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,6 @@ class Pirep extends Resource
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
$res['ident'] = $this->ident;
|
||||
$res['phase'] = $this->status;
|
||||
$res['status_text'] = PirepStatus::label($this->status);
|
||||
|
||||
// Set these to the response units
|
||||
|
||||
@@ -13,7 +13,7 @@ class SimBrief extends Resource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
|
||||
'url' => url(route('api.flights.briefing', ['id' => $this->flight_id])),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class User extends Resource
|
||||
'pilot_id' => $this->pilot_id,
|
||||
'ident' => $this->ident,
|
||||
'name' => $this->name,
|
||||
'name_private' => $this->name_private,
|
||||
'email' => $this->email,
|
||||
'avatar' => $this->resolveAvatarUrl(),
|
||||
'rank_id' => $this->rank_id,
|
||||
@@ -25,7 +24,6 @@ class User extends Resource
|
||||
'last_pirep_id' => $this->last_pirep_id,
|
||||
'flights' => $this->flights,
|
||||
'flight_time' => $this->flight_time,
|
||||
'transfer_time' => $this->transfer_time,
|
||||
'timezone' => $this->timezone,
|
||||
'state' => $this->state,
|
||||
];
|
||||
|
||||
@@ -97,11 +97,6 @@ class Airline extends Model
|
||||
$this->attributes['icao'] = strtoupper($icao);
|
||||
}
|
||||
|
||||
public function subfleets()
|
||||
{
|
||||
return $this->hasMany(Subfleet::class, 'airline_id');
|
||||
}
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->belongsTo(Flight::class, 'airline_id');
|
||||
|
||||
@@ -75,7 +75,6 @@ class Pirep extends Model
|
||||
'flight_number',
|
||||
'route_code',
|
||||
'route_leg',
|
||||
'flight_id',
|
||||
'dpt_airport_id',
|
||||
'arr_airport_id',
|
||||
'alt_airport_id',
|
||||
|
||||
+15
-16
@@ -5,12 +5,12 @@ namespace App\Models;
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
* @property string pirep_id
|
||||
* @property int fare_id
|
||||
* @property int count
|
||||
* @property Pirep pirep
|
||||
* @property Fare fare
|
||||
* @property int code
|
||||
* @property string name
|
||||
* @property float cost
|
||||
* @property float price
|
||||
* @property int capacity
|
||||
* @property int count
|
||||
*/
|
||||
class PirepFare extends Model
|
||||
{
|
||||
@@ -19,26 +19,25 @@ class PirepFare extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'pirep_id',
|
||||
'fare_id',
|
||||
'code',
|
||||
'name',
|
||||
'count',
|
||||
'price',
|
||||
'cost',
|
||||
'capacity',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'count' => 'integer',
|
||||
'count' => 'integer',
|
||||
'price' => 'float',
|
||||
'cost' => 'float',
|
||||
'capacity' => 'integer',
|
||||
];
|
||||
|
||||
public static $rules = [
|
||||
'count' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relationships
|
||||
*/
|
||||
public function fare()
|
||||
{
|
||||
return $this->belongsTo(Fare::class, 'fare_id');
|
||||
}
|
||||
|
||||
public function pirep()
|
||||
{
|
||||
return $this->belongsTo(Pirep::class, 'pirep_id');
|
||||
|
||||
+6
-12
@@ -8,28 +8,30 @@ use App\Models\Traits\ExpensableTrait;
|
||||
use App\Models\Traits\FilesTrait;
|
||||
|
||||
/**
|
||||
* Class Subfleet
|
||||
*
|
||||
* @property int id
|
||||
* @property string type
|
||||
* @property string name
|
||||
* @property int airline_id
|
||||
* @property int hub_id
|
||||
* @property string ground_handling_multiplier
|
||||
* @property Fare[] fares
|
||||
* @property float cost_block_hour
|
||||
* @property float cost_delay_minute
|
||||
* @property Airline airline
|
||||
* @property Airport hub
|
||||
* @property int airline_id
|
||||
*/
|
||||
class Subfleet extends Model
|
||||
{
|
||||
use ExpensableTrait;
|
||||
use FilesTrait;
|
||||
|
||||
public $table = 'subfleets';
|
||||
|
||||
public $fillable = [
|
||||
'airline_id',
|
||||
'hub_id',
|
||||
'type',
|
||||
'name',
|
||||
'turn_time',
|
||||
'fuel_type',
|
||||
'cost_block_hour',
|
||||
'cost_delay_minute',
|
||||
@@ -39,8 +41,6 @@ class Subfleet extends Model
|
||||
'gross_weight',
|
||||
];
|
||||
|
||||
public $table = 'subfleets';
|
||||
|
||||
public $casts = [
|
||||
'airline_id' => 'integer',
|
||||
'turn_time' => 'integer',
|
||||
@@ -56,7 +56,6 @@ class Subfleet extends Model
|
||||
public static $rules = [
|
||||
'type' => 'required',
|
||||
'name' => 'required',
|
||||
'hub_id' => 'nullable',
|
||||
'ground_handling_multiplier' => 'nullable|numeric',
|
||||
];
|
||||
|
||||
@@ -83,11 +82,6 @@ class Subfleet extends Model
|
||||
return $this->belongsTo(Airline::class, 'airline_id');
|
||||
}
|
||||
|
||||
public function hub()
|
||||
{
|
||||
return $this->hasOne(Airport::class, 'id', 'hub_id');
|
||||
}
|
||||
|
||||
public function fares()
|
||||
{
|
||||
return $this->belongsToMany(Fare::class, 'subfleet_fare')
|
||||
|
||||
@@ -19,9 +19,5 @@ class DirectiveServiceProvider extends ServiceProvider
|
||||
Blade::directive('minutestohours', function ($expr) {
|
||||
return "<?php echo \App\Support\Units\Time::minutesToHours($expr); ?>";
|
||||
});
|
||||
|
||||
Blade::directive('secstohhmm', function ($expr) {
|
||||
return "<?php echo secstohhmm($expr); ?>";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::get('simbrief/{id}', 'SimBriefController@briefing')->name('simbrief.briefing');
|
||||
Route::get('simbrief/{id}/prefile', 'SimBriefController@prefile')->name('simbrief.prefile');
|
||||
Route::get('simbrief/{id}/cancel', 'SimBriefController@cancel')->name('simbrief.cancel');
|
||||
Route::get('simbrief/{id}/generate_new', 'SimBriefController@generate_new')->name('simbrief.generate_new');
|
||||
});
|
||||
|
||||
Route::group([
|
||||
|
||||
@@ -20,7 +20,6 @@ class FlightRepository extends Repository implements CacheableInterface
|
||||
'arr_airport_id',
|
||||
'distance',
|
||||
'dpt_airport_id',
|
||||
'flight_type',
|
||||
'flight_number' => 'like',
|
||||
'route_code' => 'like',
|
||||
'route_leg' => 'like',
|
||||
@@ -94,10 +93,6 @@ class FlightRepository extends Repository implements CacheableInterface
|
||||
$where['flight_number'] = $request->input('flight_number');
|
||||
}
|
||||
|
||||
if ($request->filled('flight_type') && $request->input('flight_type') !== '0') {
|
||||
$where['flight_type'] = $request->input('flight_type');
|
||||
}
|
||||
|
||||
if ($request->filled('route_code')) {
|
||||
$where['route_code'] = $request->input('route_code');
|
||||
}
|
||||
|
||||
@@ -46,32 +46,12 @@ class AirportService extends Service
|
||||
return;
|
||||
}
|
||||
|
||||
$raw_metar = $this->metarProvider->metar($icao);
|
||||
$raw_metar = $this->metarProvider->get_metar($icao);
|
||||
if ($raw_metar && $raw_metar !== '') {
|
||||
return new Metar($raw_metar);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the METAR for a given airport
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return Metar|null
|
||||
*/
|
||||
public function getTaf($icao)
|
||||
{
|
||||
$icao = trim($icao);
|
||||
if ($icao === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$raw_taf = $this->metarProvider->taf($icao);
|
||||
if ($raw_taf && $raw_taf !== '') {
|
||||
return new Metar($raw_taf, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup an airport's information from a remote provider. This handles caching
|
||||
* the data internally
|
||||
|
||||
@@ -92,6 +92,6 @@ class CronService extends Service
|
||||
|
||||
// More than 5 minutes... there's a problem
|
||||
$diff = $dt_now->diff($dt);
|
||||
return $diff->i > 60 * 12; // Hasn't run for 12 hours
|
||||
return $diff->i > 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class FareService extends Service
|
||||
{
|
||||
if (filled($pivot->price)) {
|
||||
if (strpos($pivot->price, '%', -1) !== false) {
|
||||
$fare->price = Math::getPercent($fare->price, $pivot->price);
|
||||
$fare->price = Math::addPercent($fare->price, $pivot->price);
|
||||
} else {
|
||||
$fare->price = $pivot->price;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class FareService extends Service
|
||||
|
||||
if (filled($pivot->cost)) {
|
||||
if (strpos($pivot->cost, '%', -1) !== false) {
|
||||
$fare->cost = Math::getPercent($fare->cost, $pivot->cost);
|
||||
$fare->cost = Math::addPercent($fare->cost, $pivot->cost);
|
||||
} else {
|
||||
$fare->cost = $pivot->cost;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class FareService extends Service
|
||||
|
||||
if (filled($pivot->capacity)) {
|
||||
if (strpos($pivot->capacity, '%', -1) !== false) {
|
||||
$fare->capacity = floor(Math::getPercent($fare->capacity, $pivot->capacity));
|
||||
$fare->capacity = floor(Math::addPercent($fare->capacity, $pivot->capacity));
|
||||
} else {
|
||||
$fare->capacity = floor($pivot->capacity);
|
||||
}
|
||||
@@ -286,7 +286,9 @@ class FareService extends Service
|
||||
*/
|
||||
public function getForPirep(Pirep $pirep)
|
||||
{
|
||||
return PirepFare::where('pirep_id', $pirep->id)->get();
|
||||
$found_fares = PirepFare::where('pirep_id', $pirep->id)->get();
|
||||
|
||||
return $found_fares;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,8 +313,6 @@ class FareService extends Service
|
||||
$fare['pirep_id'] = $pirep->id;
|
||||
// other fields: ['fare_id', 'count']
|
||||
|
||||
Log::info('Saving fare pirep='.$pirep->id.', fare='.$fare['count']);
|
||||
|
||||
$field = new PirepFare($fare);
|
||||
$field->save();
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class PirepFinanceService extends Service
|
||||
public function payFuelCosts(Pirep $pirep): void
|
||||
{
|
||||
$ap = $pirep->dpt_airport;
|
||||
$fuel_used = $pirep->fuel_used;
|
||||
$fuel_used = $pirep->block_fuel;
|
||||
|
||||
$debit = Money::createFromAmount($fuel_used * $ap->fuel_jeta_cost);
|
||||
Log::info('Finance: Fuel cost, (fuel='.$fuel_used.', cost='.$ap->fuel_jeta_cost.') D='
|
||||
|
||||
@@ -137,13 +137,6 @@ class FlightService extends Service
|
||||
{
|
||||
/** @var \Illuminate\Support\Collection $subfleets */
|
||||
$subfleets = $flight->subfleets;
|
||||
|
||||
// If no subfleets assigned to a flight get users allowed subfleets
|
||||
if ($subfleets === null || $subfleets->count() === 0) {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
}
|
||||
|
||||
// If subfleets are still empty return the flight
|
||||
if ($subfleets === null || $subfleets->count() === 0) {
|
||||
return $flight;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,10 @@ class SubfleetImporter extends ImportExport
|
||||
* Should match the database fields, for the most part
|
||||
*/
|
||||
public static $columns = [
|
||||
'airline' => 'required',
|
||||
'type' => 'required',
|
||||
'name' => 'required',
|
||||
'fuel_type' => 'nullable',
|
||||
'cost_block_hour' => 'nullable',
|
||||
'cost_delay_minute' => 'nullable',
|
||||
'ground_handling_multiplier' => 'nullable',
|
||||
'cargo_capacity' => 'nullable',
|
||||
'fuel_capacity' => 'nullable',
|
||||
'gross_weight' => 'nullable',
|
||||
'fares' => 'nullable',
|
||||
'airline' => 'required',
|
||||
'type' => 'required',
|
||||
'name' => 'required',
|
||||
'fares' => 'nullable',
|
||||
];
|
||||
|
||||
private $fareSvc;
|
||||
|
||||
@@ -6,9 +6,6 @@ use App\Contracts\ImportExport;
|
||||
use App\Contracts\Service;
|
||||
use App\Models\Airport;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Fare;
|
||||
use App\Models\Flight;
|
||||
use App\Models\FlightFieldValue;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\ImportExport\AircraftImporter;
|
||||
use App\Services\ImportExport\AirportImporter;
|
||||
@@ -212,7 +209,7 @@ class ImportService extends Service
|
||||
public function importFares($csv_file, bool $delete_previous = true)
|
||||
{
|
||||
if ($delete_previous) {
|
||||
Fare::truncate();
|
||||
// TODO: Delete all from: fares
|
||||
}
|
||||
|
||||
$importer = new FareImporter();
|
||||
@@ -232,8 +229,7 @@ class ImportService extends Service
|
||||
public function importFlights($csv_file, bool $delete_previous = true)
|
||||
{
|
||||
if ($delete_previous) {
|
||||
Flight::truncate();
|
||||
FlightFieldValue::truncate();
|
||||
// TODO: Delete all from: flights, flight_field_values
|
||||
}
|
||||
|
||||
$importer = new FlightImporter();
|
||||
|
||||
@@ -9,16 +9,13 @@ use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Return the raw METAR/TAF string from the NOAA Aviation Weather Service
|
||||
* Return the raw METAR string from the NOAA Aviation Weather Service
|
||||
*/
|
||||
class AviationWeather extends Metar
|
||||
{
|
||||
private const METAR_URL =
|
||||
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
|
||||
|
||||
private const TAF_URL =
|
||||
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
|
||||
|
||||
private $httpClient;
|
||||
|
||||
public function __construct(HttpClient $httpClient)
|
||||
@@ -36,7 +33,7 @@ class AviationWeather extends Metar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_metar($icao): string
|
||||
protected function metar($icao): string
|
||||
{
|
||||
if ($icao === '') {
|
||||
return '';
|
||||
@@ -70,53 +67,7 @@ class AviationWeather extends Metar
|
||||
return $xml->data->METAR->raw_text->__toString();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Error reading METAR: '.$e->getMessage());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual retrieval of the TAF
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_taf($icao): string
|
||||
{
|
||||
if ($icao === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafurl = static::TAF_URL.$icao;
|
||||
|
||||
try {
|
||||
$tafres = $this->httpClient->get($tafurl, []);
|
||||
$tafxml = simplexml_load_string($tafres);
|
||||
|
||||
$tafattrs = $tafxml->data->attributes();
|
||||
if (!isset($tafattrs['num_results'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafnum_results = $tafattrs['num_results'];
|
||||
if (empty($tafnum_results)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tafnum_results = (int) $tafnum_results;
|
||||
if ($tafnum_results === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (count($tafxml->data->TAF->raw_text) === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $tafxml->data->TAF->raw_text->__toString();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Error reading TAF: '.$e->getMessage());
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Navdata;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\PirepFieldValue;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
@@ -41,16 +40,17 @@ class PirepService extends Service
|
||||
private $airportSvc;
|
||||
private $geoSvc;
|
||||
private $pirepRepo;
|
||||
private $simBriefSvc;
|
||||
private $userSvc;
|
||||
|
||||
/**
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param GeoService $geoSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserService $userSvc
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param AirportService $airportSvc
|
||||
* @param GeoService $geoSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param SimBriefService $simBriefSvc
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -59,16 +59,14 @@ class PirepService extends Service
|
||||
AircraftRepository $aircraftRepo,
|
||||
GeoService $geoSvc,
|
||||
PirepRepository $pirepRepo,
|
||||
SimBriefService $simBriefSvc,
|
||||
UserService $userSvc
|
||||
) {
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->airportSvc = $airportSvc;
|
||||
$this->aircraftRepo = $aircraftRepo;
|
||||
$this->geoSvc = $geoSvc;
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
$this->simBriefSvc = $simBriefSvc;
|
||||
$this->userSvc = $userSvc;
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +115,7 @@ class PirepService extends Service
|
||||
|
||||
// See if this user is at the current airport
|
||||
/* @noinspection NotOptimalIfConditionsInspection */
|
||||
if (setting('pilots.only_flights_from_current', false)
|
||||
if (setting('pilots.only_flights_from_current')
|
||||
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
|
||||
throw new UserNotAtAirport($user, $pirep->dpt_airport);
|
||||
}
|
||||
@@ -208,72 +206,6 @@ class PirepService extends Service
|
||||
return $pirep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize a PIREP (meaning it's been filed)
|
||||
*
|
||||
* @param Pirep $pirep
|
||||
* @param array $attrs
|
||||
* @param array PirepFieldValue[] $field_values
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return Pirep
|
||||
*/
|
||||
public function file(Pirep $pirep, array $attrs = [], array $field_values = []): Pirep
|
||||
{
|
||||
if (empty($field_values)) {
|
||||
$field_values = [];
|
||||
}
|
||||
|
||||
$attrs['state'] = PirepState::PENDING;
|
||||
$attrs['status'] = PirepStatus::ARRIVED;
|
||||
$attrs['submitted_at'] = Carbon::now('UTC');
|
||||
|
||||
$this->pirepRepo->update($attrs, $pirep->id);
|
||||
$pirep->refresh();
|
||||
|
||||
// Check if there is a simbrief_id, change it to be set to the PIREP
|
||||
// at the end of the flight when it's been filed
|
||||
if (array_key_exists('simbrief_id', $attrs)) {
|
||||
/** @var SimBrief $simbrief */
|
||||
$simbrief = SimBrief::find($attrs['simbrief_id']);
|
||||
if ($simbrief) {
|
||||
$this->simBriefSvc->attachSimbriefToPirep($pirep, $simbrief);
|
||||
}
|
||||
}
|
||||
|
||||
// Check the block times. If a block on (arrival) time isn't
|
||||
// specified, then use the time that it was submitted. It won't
|
||||
// be the most accurate, but that might be OK
|
||||
if (!$pirep->block_on_time) {
|
||||
if ($pirep->submitted_at) {
|
||||
$pirep->block_on_time = $pirep->submitted_at;
|
||||
} else {
|
||||
$pirep->block_on_time = Carbon::now('UTC');
|
||||
}
|
||||
}
|
||||
|
||||
// Check that there's a submit time
|
||||
if (!$pirep->submitted_at) {
|
||||
$pirep->submitted_at = Carbon::now('UTC');
|
||||
}
|
||||
|
||||
// Copy some fields over from Flight if we have it
|
||||
if ($pirep->flight) {
|
||||
$pirep->planned_distance = $pirep->flight->distance;
|
||||
$pirep->planned_flight_time = $pirep->flight->flight_time;
|
||||
}
|
||||
|
||||
$pirep->save();
|
||||
$pirep->refresh();
|
||||
|
||||
if (count($field_values) > 0) {
|
||||
$this->updateCustomFields($pirep->id, $field_values);
|
||||
}
|
||||
|
||||
return $pirep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find if there are duplicates to a given PIREP. Ideally, the passed
|
||||
* in PIREP hasn't been saved or gone through the create() method
|
||||
@@ -374,6 +306,18 @@ class PirepService extends Service
|
||||
return $pirep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias to submit()
|
||||
*
|
||||
* @param \App\Models\Pirep $pirep
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function file(Pirep $pirep)
|
||||
{
|
||||
return $this->submit($pirep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the PIREP. Figure out its default state
|
||||
*
|
||||
|
||||
@@ -32,7 +32,7 @@ class SimBriefService extends Service
|
||||
*
|
||||
* @return SimBrief|null
|
||||
*/
|
||||
public function downloadOfp(string $user_id, string $ofp_id, string $flight_id)
|
||||
public function checkForOfp(string $user_id, string $ofp_id, string $flight_id)
|
||||
{
|
||||
$uri = str_replace('{id}', $ofp_id, config('phpvms.simbrief_url'));
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ use App\Repositories\SubfleetRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Support\Units\Time;
|
||||
use App\Support\Utils;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use function is_array;
|
||||
@@ -255,41 +254,6 @@ class UserService extends Service
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the users that are determined to be on leave. Only goes through the
|
||||
* currently active users. If the user doesn't have a PIREP, then the creation date
|
||||
* of the user record is used to determine the difference
|
||||
*/
|
||||
public function findUsersOnLeave(): array
|
||||
{
|
||||
$leave_days = setting('pilots.auto_leave_days');
|
||||
if ($leave_days === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$return_users = [];
|
||||
|
||||
$date = Carbon::now('UTC');
|
||||
$users = User::with(['last_pirep'])->where('state', UserState::ACTIVE)->get();
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
// If they haven't submitted a PIREP, use the date that the user was created
|
||||
if (!$user->last_pirep) {
|
||||
$diff_date = $user->created_at;
|
||||
} else {
|
||||
$diff_date = $user->last_pirep->submitted_at;
|
||||
}
|
||||
|
||||
// See if the difference is larger than what the setting calls for
|
||||
if ($date->diffInDays($diff_date) > $leave_days) {
|
||||
$return_users[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $return_users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the subfleets this user is allowed access to,
|
||||
* based on their current rank
|
||||
@@ -462,7 +426,7 @@ class UserService extends Service
|
||||
$user->state = UserState::ON_LEAVE;
|
||||
$user->save();
|
||||
|
||||
event(new UserStateChanged($user, UserState::ON_LEAVE));
|
||||
event(new UserStateChanged($user, UserState::ACTIVE));
|
||||
|
||||
$user->refresh();
|
||||
return $user;
|
||||
|
||||
@@ -27,19 +27,18 @@ class Math
|
||||
return $override_rate;
|
||||
}
|
||||
|
||||
// It is a percent, so apply it
|
||||
return static::getPercent($base_rate, $override_rate);
|
||||
return static::addPercent($base_rate, $override_rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a percentage to a number
|
||||
* Add/subtract a percentage to a number
|
||||
*
|
||||
* @param $number
|
||||
* @param $percent
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function getPercent($number, $percent): float
|
||||
public static function addPercent($number, $percent): float
|
||||
{
|
||||
if (!is_numeric($number)) {
|
||||
$number = (float) $number;
|
||||
@@ -49,8 +48,6 @@ class Math
|
||||
$percent = (float) $percent;
|
||||
}
|
||||
|
||||
$val = $number * ($percent / 100);
|
||||
|
||||
return $val;
|
||||
return $number + ($number * ($percent / 100));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,11 +172,11 @@ class Metar implements \ArrayAccess
|
||||
'NSW' => 'no significant weather are observed',
|
||||
'NSC' => 'no significant clouds are observed',
|
||||
'NCD' => 'nil cloud detected',
|
||||
'SKC' => 'sky is clear',
|
||||
'SKC' => 'no significant changes expected',
|
||||
'CLR' => 'clear skies',
|
||||
'NOBS' => 'no observation',
|
||||
//
|
||||
'FEW' => 'few',
|
||||
'FEW' => 'a few',
|
||||
'SCT' => 'scattered',
|
||||
'BKN' => 'broken sky',
|
||||
'OVC' => 'overcast sky',
|
||||
@@ -523,8 +523,6 @@ class Metar implements \ArrayAccess
|
||||
|
||||
// Finally determine if it's VFR or IFR conditions
|
||||
// https://www.aviationweather.gov/cva/help
|
||||
// https://www.skybrary.aero/index.php/Visual_Meteorological_Conditions_(VMC)
|
||||
// This may be changed to ICAO standards as VMC and IMC
|
||||
$this->result['category'] = 'VFR';
|
||||
|
||||
if (array_key_exists('cavok', $this->result) && $this->result['cavok']) {
|
||||
@@ -533,7 +531,7 @@ class Metar implements \ArrayAccess
|
||||
/* @noinspection NestedPositiveIfStatementsInspection */
|
||||
if (array_key_exists('cloud_height', $this->result) && $this->result['cloud_height'] !== null) {
|
||||
if ($this->result['cloud_height']['ft'] > 3000
|
||||
&& (empty($this->result['visibility']) || $this->result['visibility']['km'] > 5)) {
|
||||
&& (empty($this->result['visibility']) || $this->result['visibility']['nmi'] > 5)) {
|
||||
$this->result['category'] = 'VFR';
|
||||
} else {
|
||||
$this->result['category'] = 'IFR';
|
||||
@@ -1233,11 +1231,10 @@ class Metar implements \ArrayAccess
|
||||
$pressure = (int) $found[2];
|
||||
if ($found[1] === 'A') {
|
||||
$pressure /= 100;
|
||||
$this->set_result_value('barometer', $this->createPressure($pressure, 'inHg'));
|
||||
} else {
|
||||
$this->set_result_value('barometer', $this->createPressure($pressure, 'hPa'));
|
||||
}
|
||||
|
||||
$this->set_result_value('barometer', $this->createPressure($pressure, 'hPa'));
|
||||
|
||||
$this->method++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -123,10 +123,6 @@ class Utils
|
||||
return $val;
|
||||
}
|
||||
|
||||
if ($result->hostname === 'localhost') {
|
||||
return 'localhost';
|
||||
}
|
||||
|
||||
// Couldn't validate a domain, see if this is an IP address?
|
||||
if (filter_var($url, FILTER_VALIDATE_IP)) {
|
||||
return $url;
|
||||
|
||||
@@ -14,7 +14,6 @@ class LiveMap extends Widget
|
||||
protected $config = [
|
||||
'height' => '800px',
|
||||
'width' => '100%',
|
||||
'table' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,8 +11,7 @@ use App\Services\AirportService;
|
||||
class Weather extends Widget
|
||||
{
|
||||
protected $config = [
|
||||
'icao' => null,
|
||||
'raw_only' => null,
|
||||
'icao' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -23,12 +22,10 @@ class Weather extends Widget
|
||||
/** @var \App\Services\AirportService $airportSvc */
|
||||
$airportSvc = app(AirportService::class);
|
||||
$metar = $airportSvc->getMetar($this->config['icao']);
|
||||
$taf = $airportSvc->getTaf($this->config['icao']);
|
||||
|
||||
return view('widgets.weather', [
|
||||
'config' => $this->config,
|
||||
'metar' => $metar,
|
||||
'taf' => $taf,
|
||||
'unit_alt' => setting('units.altitude'),
|
||||
'unit_dist' => setting('units.distance'),
|
||||
'unit_temp' => setting('units.temperature'),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Exceptions\SettingNotFound;
|
||||
use App\Repositories\KvpRepository;
|
||||
use App\Repositories\SettingRepository;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
@@ -161,7 +160,6 @@ if (!function_exists('setting')) {
|
||||
*/
|
||||
function setting($key, $default = null)
|
||||
{
|
||||
/** @var \App\Repositories\SettingRepository $settingRepo */
|
||||
$settingRepo = app(SettingRepository::class);
|
||||
|
||||
try {
|
||||
@@ -182,60 +180,12 @@ if (!function_exists('setting')) {
|
||||
if (!function_exists('setting_save')) {
|
||||
function setting_save($key, $value)
|
||||
{
|
||||
/** @var \App\Repositories\SettingRepository $settingRepo */
|
||||
$settingRepo = app(SettingRepository::class);
|
||||
$settingRepo->save($key, $value);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut for retrieving a KVP
|
||||
*/
|
||||
if (!function_exists('kvp')) {
|
||||
/**
|
||||
* Read a setting from the KVP repository
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $default
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function kvp(string $key, $default = null)
|
||||
{
|
||||
/** @var KvpRepository $kvpRepo */
|
||||
$kvpRepo = app(KvpRepository::class);
|
||||
|
||||
try {
|
||||
$value = $kvpRepo->get($key, $default);
|
||||
} catch (Exception $e) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut for retrieving a KVP
|
||||
*/
|
||||
if (!function_exists('kvp_save')) {
|
||||
/**
|
||||
* Read a setting from the KVP repository
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function kvp_save(string $key, string $value)
|
||||
{
|
||||
/** @var KvpRepository $kvpRepo */
|
||||
$kvpRepo = app(KvpRepository::class);
|
||||
$kvpRepo->save($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrap the asset URL in the publicBaseUrl that's been
|
||||
* set
|
||||
@@ -357,20 +307,6 @@ if (!function_exists('show_datetime_format')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('secstohhmm')) {
|
||||
/**
|
||||
* Convert seconds to hhmm format
|
||||
*
|
||||
* @param $seconds
|
||||
*/
|
||||
function secstohhmm($seconds)
|
||||
{
|
||||
$seconds = round($seconds);
|
||||
$hhmm = sprintf('%02d%02d', ($seconds / 3600), ($seconds / 60 % 60));
|
||||
echo $hhmm;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('_fmt')) {
|
||||
/**
|
||||
* Replace strings
|
||||
|
||||
@@ -73,7 +73,6 @@ class application extends Illuminate\Foundation\Application
|
||||
public function setPublicPath($publicDirPath)
|
||||
{
|
||||
$this->publicDirPath = $publicDirPath;
|
||||
$this->instance('path.public', $publicDirPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +103,11 @@ class application extends Illuminate\Foundation\Application
|
||||
return $this->basePath.DS.'config'.($path ? DS.$path : $path);
|
||||
}
|
||||
|
||||
/*public function environmentPath()
|
||||
{
|
||||
return $this->environmentPath ?: $this->basePath;
|
||||
}*/
|
||||
|
||||
public function langPath()
|
||||
{
|
||||
return $this->resourcePath().DS.'lang';
|
||||
@@ -111,11 +115,7 @@ class application extends Illuminate\Foundation\Application
|
||||
|
||||
public function publicPath()
|
||||
{
|
||||
if (empty($this->publicDirPath)) {
|
||||
return $this->basePath.DS.'public';
|
||||
}
|
||||
|
||||
return $this->publicDirPath;
|
||||
return $this->publicDirPath ?: $this->basePath.DS.'public';
|
||||
}
|
||||
|
||||
public function resourcePath($path = '')
|
||||
|
||||
+1
-2
@@ -58,8 +58,7 @@
|
||||
"webpatser/laravel-uuid": "~3.0",
|
||||
"oomphinc/composer-installers-extender": "^1.1",
|
||||
"laravel/ui": "^2.0",
|
||||
"madnest/madzipper": "^1.0",
|
||||
"elcobvg/laravel-opcache": "^0.4.1"
|
||||
"madnest/madzipper": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.0",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user