Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4a42c53ba | ||
|
|
a4b90fcce3 |
@@ -1,10 +1,6 @@
|
|||||||
#
|
#
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.js]
|
[*.js]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
@@ -27,4 +23,4 @@ indent_style = tab
|
|||||||
# Matches the exact files either package.json or .travis.yml
|
# Matches the exact files either package.json or .travis.yml
|
||||||
[{package.json, .travis.yml}]
|
[{package.json, .travis.yml}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
36
.github/scripts/version.sh
vendored
36
.github/scripts/version.sh
vendored
@@ -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
|
|
||||||
248
.github/workflows/build.yml
vendored
248
.github/workflows/build.yml
vendored
@@ -1,248 +0,0 @@
|
|||||||
name: 'Build'
|
|
||||||
on: ['push', 'pull_request', 'workflow_dispatch', 'release']
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
if: github.repository == 'nabeelio/phpvms'
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
matrix:
|
|
||||||
php-versions: ['8.0', '8.1']
|
|
||||||
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') }}
|
|
||||||
|
|
||||||
# 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
|
|
||||||
sleep 15
|
|
||||||
# Downgrade composer version to 1.x
|
|
||||||
composer install --dev --no-interaction --verbose
|
|
||||||
cp .github/scripts/env.php env.php
|
|
||||||
cp .github/scripts/phpunit.xml phpunit.xml
|
|
||||||
php artisan database:create --reset
|
|
||||||
php artisan migrate:refresh --seed
|
|
||||||
|
|
||||||
- name: Run Tests
|
|
||||||
run: |
|
|
||||||
export PHP_CS_FIXER_IGNORE_ENV=1
|
|
||||||
#vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no
|
|
||||||
vendor/bin/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-20.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: '8.0'
|
|
||||||
|
|
||||||
- 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
|
|
||||||
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-20.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: 8.0
|
|
||||||
|
|
||||||
- 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
|
|
||||||
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 }}'
|
|
||||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -22,7 +22,6 @@ storage/*.sqlite
|
|||||||
.env.*.php
|
.env.*.php
|
||||||
.env.php
|
.env.php
|
||||||
.env
|
.env
|
||||||
.env.*
|
|
||||||
.env.bak
|
.env.bak
|
||||||
env.php
|
env.php
|
||||||
.env.generated
|
.env.generated
|
||||||
@@ -31,6 +30,8 @@ env.php
|
|||||||
Homestead.json
|
Homestead.json
|
||||||
LocalValetDriver.php
|
LocalValetDriver.php
|
||||||
docker-compose-profiler.yml
|
docker-compose-profiler.yml
|
||||||
|
sync.sh
|
||||||
|
.env.*
|
||||||
|
|
||||||
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
|
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
|
||||||
.rocketeer/
|
.rocketeer/
|
||||||
@@ -75,16 +76,4 @@ error_log
|
|||||||
.sass-cache
|
.sass-cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/config.php
|
/config.php
|
||||||
/config.bak.php
|
|
||||||
/VERSION
|
/VERSION
|
||||||
sync.sh
|
|
||||||
|
|
||||||
###> friendsofphp/php-cs-fixer ###
|
|
||||||
/.php-cs-fixer.php
|
|
||||||
/.php-cs-fixer.cache
|
|
||||||
###< friendsofphp/php-cs-fixer ###
|
|
||||||
|
|
||||||
###> phpunit/phpunit ###
|
|
||||||
/phpunit.xml
|
|
||||||
.phpunit.result.cache
|
|
||||||
###< phpunit/phpunit ###
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ RedirectMatch 403 ^/composer.phar
|
|||||||
RedirectMatch 403 ^/env.php.*?$
|
RedirectMatch 403 ^/env.php.*?$
|
||||||
RedirectMatch 403 ^/env.php
|
RedirectMatch 403 ^/env.php
|
||||||
RedirectMatch 403 ^/env.php$
|
RedirectMatch 403 ^/env.php$
|
||||||
RedirectMatch 403 ^/config.php$
|
|
||||||
RedirectMatch 403 ^/config.bak.php$
|
|
||||||
RedirectMatch 403 ^/Makefile
|
RedirectMatch 403 ^/Makefile
|
||||||
RedirectMatch 403 ^/package.json
|
RedirectMatch 403 ^/package.json
|
||||||
RedirectMatch 403 ^/package-lock.json
|
RedirectMatch 403 ^/package-lock.json
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of PHP CS Fixer.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
|
||||||
*
|
|
||||||
* This source file is subject to the MIT license that is bundled
|
|
||||||
* with this source code in the file LICENSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$header = <<<'EOF'
|
|
||||||
This file is part of PHP CS Fixer.
|
|
||||||
(c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
|
||||||
This source file is subject to the MIT license that is bundled
|
|
||||||
with this source code in the file LICENSE.
|
|
||||||
EOF;
|
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
|
||||||
->ignoreVCSIgnored(true)
|
|
||||||
->exclude('tests/data')
|
|
||||||
->exclude('storage')
|
|
||||||
->exclude('resources')
|
|
||||||
->in(__DIR__)
|
|
||||||
->append([
|
|
||||||
__DIR__.'/dev-tools/doc.php',
|
|
||||||
// __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
|
|
||||||
__FILE__,
|
|
||||||
])
|
|
||||||
;
|
|
||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
|
||||||
$config
|
|
||||||
->setRiskyAllowed(true)
|
|
||||||
->setRules([
|
|
||||||
'@PSR2' => true,
|
|
||||||
'strict_param' => true,
|
|
||||||
'no_php4_constructor' => true,
|
|
||||||
'no_extra_blank_lines' => true,
|
|
||||||
'no_superfluous_elseif' => true,
|
|
||||||
'single_line_comment_style' => false,
|
|
||||||
'simple_to_complex_string_variable' => true,
|
|
||||||
'array_syntax' => [
|
|
||||||
'syntax' => 'short',
|
|
||||||
],
|
|
||||||
'binary_operator_spaces' => [
|
|
||||||
'operators' => [
|
|
||||||
'=>' => 'align_single_space_minimal'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/*
|
|
||||||
'blank_line_before_statement' => [
|
|
||||||
'statements' => [
|
|
||||||
'declare',
|
|
||||||
'for',
|
|
||||||
'return',
|
|
||||||
'throw',
|
|
||||||
'try',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
*/
|
|
||||||
])
|
|
||||||
->setFinder($finder);
|
|
||||||
|
|
||||||
return $config;
|
|
||||||
37
.php_cs
Normal file
37
.php_cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->in('app')
|
||||||
|
->in('config');
|
||||||
|
|
||||||
|
return PhpCsFixer\Config::create()
|
||||||
|
->setHideProgress(true)
|
||||||
|
->setUsingCache(false)
|
||||||
|
->setRiskyAllowed(true)
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'strict_param' => true,
|
||||||
|
'no_php4_constructor' => true,
|
||||||
|
'no_extra_blank_lines' => true,
|
||||||
|
'no_superfluous_elseif' => true,
|
||||||
|
'single_line_comment_style' => false,
|
||||||
|
'simple_to_complex_string_variable' => true,
|
||||||
|
'array_syntax' => [
|
||||||
|
'syntax' => 'short',
|
||||||
|
],
|
||||||
|
'binary_operator_spaces' => [
|
||||||
|
'align_double_arrow' => true,
|
||||||
|
],
|
||||||
|
/*
|
||||||
|
'blank_line_before_statement' => [
|
||||||
|
'statements' => [
|
||||||
|
'declare',
|
||||||
|
'for',
|
||||||
|
'return',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
])
|
||||||
|
->setFinder($finder);
|
||||||
161
.travis.yml
Normal file
161
.travis.yml
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
#
|
||||||
|
# Travis CI config file
|
||||||
|
#
|
||||||
|
|
||||||
|
language: php
|
||||||
|
php:
|
||||||
|
- '7.4'
|
||||||
|
- '7.3'
|
||||||
|
- '7.2'
|
||||||
|
|
||||||
|
#env:
|
||||||
|
# - DB=mysql
|
||||||
|
# - DB=mariadb
|
||||||
|
|
||||||
|
cache:
|
||||||
|
# Cache lives for 10 min
|
||||||
|
# Default of 3m might not be long enough for all the runs
|
||||||
|
timeout: 600
|
||||||
|
directories:
|
||||||
|
- "$HOME/.composer/cache"
|
||||||
|
- "$HOME/.npm"
|
||||||
|
|
||||||
|
services:
|
||||||
|
- mysql
|
||||||
|
|
||||||
|
#addons:
|
||||||
|
# mariadb: '10.2'
|
||||||
|
|
||||||
|
install:
|
||||||
|
- php --version
|
||||||
|
- mysql --version
|
||||||
|
- composer install --dev --no-interaction --verbose
|
||||||
|
- npm i tar-to-zip -g
|
||||||
|
- cp .travis/env.travis.php env.php
|
||||||
|
- cp .travis/phpunit.travis.xml phpunit.xml
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- php artisan database:create --reset
|
||||||
|
- php artisan migrate:refresh --seed
|
||||||
|
|
||||||
|
script:
|
||||||
|
- vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no
|
||||||
|
- vendor/bin/phpunit --debug --verbose
|
||||||
|
|
||||||
|
after_failure:
|
||||||
|
- cat storage/logs/*.log
|
||||||
|
|
||||||
|
# Refer to: https://github.com/doctrine/dbal/blob/master/.travis.yml#L39
|
||||||
|
jobs:
|
||||||
|
include:
|
||||||
|
# Different test stages
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.2 + MySQL 5.7
|
||||||
|
# php: 7.2
|
||||||
|
# env: DB=mysql
|
||||||
|
# services:
|
||||||
|
# - mysql
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.3 + MySQL 5.7
|
||||||
|
# php: 7.3
|
||||||
|
# env: DB=mysql
|
||||||
|
# services:
|
||||||
|
# - mysql
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.4 + MySQL 5.7
|
||||||
|
# php: 7.4
|
||||||
|
# env: DB=mysql
|
||||||
|
# services:
|
||||||
|
# - mysql
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.2 + MariaDB 10.1
|
||||||
|
# php: 7.2
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.1'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.3 + MariaDB 10.1
|
||||||
|
# php: 7.3
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.1'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.4 + MariaDB 10.1
|
||||||
|
# php: 7.4
|
||||||
|
# env: DB=mariadb MARIADB_VERSION=10.1
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.1'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.2 + MariaDB 10.2
|
||||||
|
# php: 7.2
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.2'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.3 + MariaDB 10.3
|
||||||
|
# php: 7.3
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.2'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.4 + MariaDB 10.2
|
||||||
|
# php: 7.4
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.2'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.2 + MariaDB 10.3
|
||||||
|
# php: 7.2
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.3'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.3 + MariaDB 10.3
|
||||||
|
# php: 7.3
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.3'
|
||||||
|
# - stage: Test
|
||||||
|
# name: PHP 7.4 + MariaDB 10.3
|
||||||
|
# php: 7.4
|
||||||
|
# env: DB=mariadb
|
||||||
|
# addons:
|
||||||
|
# mariadb: '10.3'
|
||||||
|
|
||||||
|
# Just packages up a release
|
||||||
|
- stage: package
|
||||||
|
script: skip
|
||||||
|
before_deploy:
|
||||||
|
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
|
||||||
|
|
||||||
|
# Configure the conditional deployment
|
||||||
|
# https://docs.travis-ci.com/user/deployment/#examples-of-conditional-deployment
|
||||||
|
deploy:
|
||||||
|
- provider: script
|
||||||
|
skip_cleanup: true
|
||||||
|
script: ./.travis/deploy_script.sh
|
||||||
|
on:
|
||||||
|
all_branches: true
|
||||||
|
repo: nabeelio/phpvms
|
||||||
|
php: '7.4'
|
||||||
|
tags: false
|
||||||
|
|
||||||
|
# RELEASE STAGE
|
||||||
|
# Only runs when there's a tag applied to this release (tag should be the version)
|
||||||
|
# This uses Github Releases and posts it there (provider: releases)
|
||||||
|
# https://docs.travis-ci.com/user/deployment/releases
|
||||||
|
- stage: release
|
||||||
|
script: skip
|
||||||
|
before_deploy:
|
||||||
|
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
|
||||||
|
- ./.travis/deploy_script.sh
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
skip_cleanup: true
|
||||||
|
api_key: $GITHUB_TOKEN
|
||||||
|
file_glob: true
|
||||||
|
file: build/*
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
repo: nabeelio/phpvms
|
||||||
|
php: '7.4'
|
||||||
100
.github/scripts/build.sh → .travis/deploy_script.sh
Normal file → Executable file
100
.github/scripts/build.sh → .travis/deploy_script.sh
Normal file → Executable file
@@ -1,12 +1,52 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ "$TRAVIS" != "true" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $TRAVIS_BUILD_DIR
|
||||||
|
|
||||||
|
if test "$TRAVIS_TAG"; then
|
||||||
|
VERSION=$TRAVIS_TAG
|
||||||
|
|
||||||
|
# Pass in the tag as the version to write out
|
||||||
|
php artisan phpvms:version --write --write-full-version "${VERSION}"
|
||||||
|
FULL_VERSION=$(php artisan phpvms:version)
|
||||||
|
else
|
||||||
|
echo "On branch $TRAVIS_BRANCH"
|
||||||
|
|
||||||
|
if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
|
||||||
|
echo "Not on valid branch, exiting"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write the version out but place the branch ID in there
|
||||||
|
# This is only for the dev branch
|
||||||
|
BASE_VERSION=$(php artisan phpvms:version --base-only)
|
||||||
|
|
||||||
|
# This now includes the pre-release version, so "-dev" by default
|
||||||
|
VERSION=${BASE_VERSION}
|
||||||
|
|
||||||
|
# Don't pass in a version here, just write out the latest hash
|
||||||
|
php artisan phpvms:version --write "${VERSION}"
|
||||||
|
FULL_VERSION=$(php artisan phpvms:version)
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILE_NAME="phpvms-${VERSION}"
|
||||||
|
TAR_NAME="$FILE_NAME.tar.gz"
|
||||||
|
ZIP_NAME="$FILE_NAME.zip"
|
||||||
|
|
||||||
echo "Version: ${VERSION}"
|
echo "Version: ${VERSION}"
|
||||||
echo "Full Version: ${FULL_VERSION}"
|
echo "Full Version: ${FULL_VERSION}"
|
||||||
echo "Package name: ${TAR_NAME}"
|
echo "Package name: ${TAR_NAME}"
|
||||||
echo "Current directory: ${BASE_DIR}"
|
|
||||||
|
echo "==========================="
|
||||||
|
|
||||||
echo "Cleaning files"
|
echo "Cleaning files"
|
||||||
|
|
||||||
|
rm -rf vendor
|
||||||
|
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||||
|
|
||||||
# Leftover individual files to delete
|
# Leftover individual files to delete
|
||||||
declare -a remove_files=(
|
declare -a remove_files=(
|
||||||
.git
|
.git
|
||||||
@@ -15,10 +55,7 @@ declare -a remove_files=(
|
|||||||
.idea
|
.idea
|
||||||
.travis
|
.travis
|
||||||
docker
|
docker
|
||||||
node_modules
|
|
||||||
vendor/willdurand/geocoder/tests
|
|
||||||
_ide_helper.php
|
_ide_helper.php
|
||||||
.env
|
|
||||||
.dockerignore
|
.dockerignore
|
||||||
.dpl
|
.dpl
|
||||||
.editorconfig
|
.editorconfig
|
||||||
@@ -26,7 +63,6 @@ declare -a remove_files=(
|
|||||||
.eslintrc
|
.eslintrc
|
||||||
.php_cs
|
.php_cs
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
.php-cs-fixer.php
|
|
||||||
.phpstorm.meta.php
|
.phpstorm.meta.php
|
||||||
.styleci.yml
|
.styleci.yml
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
@@ -34,15 +70,15 @@ declare -a remove_files=(
|
|||||||
intellij_style.xml
|
intellij_style.xml
|
||||||
config.php
|
config.php
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
docker-compose.local.yml
|
|
||||||
Makefile
|
Makefile
|
||||||
phpcs.xml
|
phpcs.xml
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
phpvms.iml
|
phpvms.iml
|
||||||
Procfile
|
Procfile
|
||||||
phpstan.neon
|
phpstan.neon
|
||||||
symfony.lock
|
node_modules
|
||||||
composer.phar
|
composer.phar
|
||||||
|
vendor/willdurand/geocoder/tests
|
||||||
)
|
)
|
||||||
|
|
||||||
for file in "${remove_files[@]}"; do
|
for file in "${remove_files[@]}"; do
|
||||||
@@ -71,32 +107,44 @@ mkdir -p storage/framework/cache
|
|||||||
mkdir -p storage/framework/sessions
|
mkdir -p storage/framework/sessions
|
||||||
mkdir -p storage/framework/views
|
mkdir -p storage/framework/views
|
||||||
|
|
||||||
|
# Regenerate the autoloader and classes
|
||||||
|
composer dump-autoload
|
||||||
|
make clean
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
ls -al $TRAVIS_BUILD_DIR/../
|
||||||
|
|
||||||
echo "Current directory contents"
|
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR .
|
||||||
ls -al $BASE_DIR
|
|
||||||
|
|
||||||
echo "Parent directory contents"
|
|
||||||
ls -al $BASE_DIR/../
|
|
||||||
|
|
||||||
echo "Calling find"
|
|
||||||
find $BASE_DIR/../ -type d -maxdepth 2
|
|
||||||
|
|
||||||
tar -czf $TAR_NAME -C $BASE_DIR --xform 's:^\./::' . [--show-transformed-names|--show-stored-names]
|
|
||||||
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
||||||
|
tar2zip $TAR_NAME
|
||||||
cd $BASE_DIR;
|
|
||||||
zip -r $ZIP_NAME ./
|
|
||||||
sha256sum $ZIP_NAME >"$ZIP_NAME.sha256"
|
sha256sum $ZIP_NAME >"$ZIP_NAME.sha256"
|
||||||
|
|
||||||
mv $ZIP_NAME /tmp
|
|
||||||
mv "$ZIP_NAME.sha256" /tmp
|
|
||||||
|
|
||||||
ls -al /tmp
|
ls -al /tmp
|
||||||
|
|
||||||
echo "Moving to dist"
|
echo "Uploading to S3"
|
||||||
mkdir -p $BASE_DIR/dist
|
mkdir -p $TRAVIS_BUILD_DIR/build
|
||||||
cd $BASE_DIR/dist
|
cd $TRAVIS_BUILD_DIR/build
|
||||||
|
|
||||||
mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256" .
|
mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256" .
|
||||||
|
artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256 $ZIP_NAME.sha256
|
||||||
|
|
||||||
|
# Upload the version for a tagged release. Move to a version file in different
|
||||||
|
# tags. Within phpVMS, we have an option of which version to track in the admin
|
||||||
|
if test "$TRAVIS_TAG"; then
|
||||||
|
echo "Uploading release version file"
|
||||||
|
cp "$TRAVIS_BUILD_DIR/VERSION" release_version
|
||||||
|
artifacts upload --target-paths "/" release_version
|
||||||
|
else
|
||||||
|
echo "Uploading ${TRAVIS_BRANCH}_version file"
|
||||||
|
cp $TRAVIS_BUILD_DIR/VERSION ${TRAVIS_BRANCH}_version
|
||||||
|
artifacts upload --target-paths "/" ${TRAVIS_BRANCH}_version
|
||||||
|
fi
|
||||||
|
|
||||||
|
#if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
|
||||||
|
# echo "Skipping Discord branch update broadcast"
|
||||||
|
#else
|
||||||
|
curl -X POST \
|
||||||
|
--data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME (${FULL_VERSION})\"}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
$DISCORD_WEBHOOK_URL
|
||||||
|
#fi
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
exit();
|
||||||
|
?>
|
||||||
|
|
||||||
APP_ENV="dev"
|
APP_ENV="dev"
|
||||||
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
|
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
|
||||||
APP_URL="http://localhost"
|
APP_URL="http://localhost"
|
||||||
@@ -8,7 +12,7 @@ APP_LOCALE="en"
|
|||||||
PHPVMS_INSTALLED="true"
|
PHPVMS_INSTALLED="true"
|
||||||
|
|
||||||
APP_LOG="daily"
|
APP_LOG="daily"
|
||||||
LOG_LEVEL="debug"
|
APP_LOG_LEVEL="debug"
|
||||||
APP_LOG_MAX_FILES="3"
|
APP_LOG_MAX_FILES="3"
|
||||||
|
|
||||||
DB_CONNECTION="mysql"
|
DB_CONNECTION="mysql"
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
<directory suffix=".php">./app</directory>
|
<directory suffix=".php">./app</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<!--<listeners>
|
<listeners>
|
||||||
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
|
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
|
||||||
</listeners>-->
|
</listeners>
|
||||||
<php>
|
<php>
|
||||||
<ini name="error_reporting" value="E_ALL"/>
|
<ini name="error_reporting" value="E_ALL"/>
|
||||||
<ini name="display_errors" value="On"/>
|
<ini name="display_errors" value="On"/>
|
||||||
21
Dockerfile
21
Dockerfile
@@ -1,35 +1,28 @@
|
|||||||
FROM php:8.1-fpm-alpine3.15
|
FROM php:7.4-fpm-alpine
|
||||||
|
|
||||||
WORKDIR /var/www/
|
WORKDIR /var/www/
|
||||||
|
|
||||||
# Setup composer
|
RUN apk add gmp-dev
|
||||||
COPY --from=composer:2.2.7 /usr/bin/composer /usr/local/bin/composer
|
RUN curl --silent --show-error https://getcomposer.org/installer | php
|
||||||
|
|
||||||
RUN apk add gmp-dev icu-dev zlib-dev libpng-dev libzip-dev zip
|
|
||||||
|
|
||||||
# Copy any config files in
|
# Copy any config files in
|
||||||
COPY resources/docker/php/ext-opcache.ini $PHP_INI_DIR/conf.d/
|
COPY resources/docker/php/ext-opcache.ini $PHP_INI_DIR/conf.d/
|
||||||
COPY resources/docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
|
COPY resources/docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
RUN ln -sf /dev/stderr /var/log/fpm-error.log
|
||||||
|
|
||||||
RUN docker-php-ext-install \
|
RUN docker-php-ext-install \
|
||||||
calendar \
|
calendar \
|
||||||
intl \
|
|
||||||
pdo_mysql \
|
pdo_mysql \
|
||||||
gd \
|
|
||||||
gmp \
|
gmp \
|
||||||
bcmath \
|
opcache && \
|
||||||
opcache \
|
docker-php-ext-enable pdo_mysql opcache
|
||||||
zip && \
|
|
||||||
docker-php-ext-enable pdo_mysql opcache bcmath zip intl
|
|
||||||
|
|
||||||
COPY . /var/www/
|
COPY . /var/www/
|
||||||
RUN composer install \
|
RUN php composer.phar install \
|
||||||
--ignore-platform-reqs \
|
--ignore-platform-reqs \
|
||||||
--no-interaction \
|
--no-interaction \
|
||||||
--no-plugins \
|
--no-plugins \
|
||||||
--no-scripts \
|
--no-scripts \
|
||||||
--prefer-dist
|
--prefer-dist
|
||||||
|
|
||||||
#RUN chown -R www-data:www-data /var/www
|
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|||||||
5
LICENSE
5
LICENSE
@@ -1,3 +1,5 @@
|
|||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
Copyright (c) 2017, phpvms - http://www.phpvms.net
|
Copyright (c) 2017, phpvms - http://www.phpvms.net
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
@@ -15,9 +17,6 @@ modification, are permitted provided that the following conditions are met:
|
|||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
* A "powered by phpvms" is required in page footers, unless the license has
|
|
||||||
purchased to omit it.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
|||||||
31
Makefile
31
Makefile
@@ -74,13 +74,17 @@ reload-db:
|
|||||||
tests: test
|
tests: test
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test: phpcs
|
||||||
@#php artisan database:create --reset
|
#php artisan database:create --reset
|
||||||
@vendor/bin/phpunit --verbose
|
vendor/bin/phpunit --debug --verbose
|
||||||
|
|
||||||
.PHONY: phpcs
|
.PHONY: phpcs
|
||||||
phpcs:
|
phpcs:
|
||||||
@PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no
|
@vendor/bin/php-cs-fixer fix --config=.php_cs -v --diff --diff-format=udiff --dry-run
|
||||||
|
|
||||||
|
#.PHONY: phpstan
|
||||||
|
#phpstan:
|
||||||
|
# vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app
|
||||||
|
|
||||||
.PHONY: replay-acars
|
.PHONY: replay-acars
|
||||||
replay-acars:
|
replay-acars:
|
||||||
@@ -91,6 +95,11 @@ replay-acars:
|
|||||||
sass-watch:
|
sass-watch:
|
||||||
sass --watch public/assets/admin/sass/paper-dashboard.scss:public/assets/admin/css/paper-dashboard.css
|
sass --watch public/assets/admin/sass/paper-dashboard.scss:public/assets/admin/css/paper-dashboard.css
|
||||||
|
|
||||||
|
.PHONY: schema
|
||||||
|
schema:
|
||||||
|
#php artisan infyom:scaffold Aircraft --fieldsFile=database/schema/aircraft.json
|
||||||
|
echo ""
|
||||||
|
|
||||||
.PHONY: deploy-package
|
.PHONY: deploy-package
|
||||||
deploy-package:
|
deploy-package:
|
||||||
./.travis/deploy_script.sh
|
./.travis/deploy_script.sh
|
||||||
@@ -100,9 +109,17 @@ reset-installer:
|
|||||||
@php artisan database:create --reset
|
@php artisan database:create --reset
|
||||||
@php artisan migrate:refresh --seed
|
@php artisan migrate:refresh --seed
|
||||||
|
|
||||||
.PHONY: docker-test
|
.PHONY: docker
|
||||||
docker-test:
|
docker:
|
||||||
@docker compose -f docker-compose.dev.yml up
|
@mkdir -p $(CURR_PATH)/tmp/mysql
|
||||||
|
|
||||||
|
-docker rm -f phpvms
|
||||||
|
docker build -t phpvms .
|
||||||
|
docker run --name=phpvms \
|
||||||
|
-v $(CURR_PATH):/var/www/ \
|
||||||
|
-v $(CURR_PATH)/tmp/mysql:/var/lib/mysql \
|
||||||
|
-p 8080:80 \
|
||||||
|
phpvms
|
||||||
|
|
||||||
.PHONY: docker-clean
|
.PHONY: docker-clean
|
||||||
docker-clean:
|
docker-clean:
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -1,17 +1,20 @@
|
|||||||
# 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
|
A full distribution, with all of the composer dependencies, is available at this
|
||||||
[GitHub Releases](https://github.com/nabeelio/phpvms/releases) link.
|
[GitHub Releases](https://github.com/nabeelio/phpvms/releases) link.
|
||||||
|
|
||||||
### Requirements
|
|
||||||
|
|
||||||
- PHP 8.0+, extensions:
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- PHP 7.1+, extensions:
|
||||||
- cURL
|
- cURL
|
||||||
- JSON
|
- JSON
|
||||||
- mbstring
|
- mbstring
|
||||||
@@ -21,25 +24,24 @@ A full distribution, with all of the composer dependencies, is available at this
|
|||||||
- Database:
|
- Database:
|
||||||
- MySQL 5.5+ (or MySQL variant, including MariaDB and Percona)
|
- MySQL 5.5+ (or MySQL variant, including MariaDB and Percona)
|
||||||
|
|
||||||
[View more details on requirements](https://docs.phpvms.net/requirements)
|
[View more details on requirements](http://docs.phpvms.net/setup/requirements)
|
||||||
|
|
||||||
### Installer
|
## Installer
|
||||||
|
|
||||||
1. Upload to your server
|
1. Upload to your server
|
||||||
1. Visit the site, and follow the link to the installer
|
1. Visit the site, and follow the link to the installer
|
||||||
|
|
||||||
[View installation details](https://docs.phpvms.net/installation/installation)
|
[View installation details](http://docs.phpvms.net/setup/installation)
|
||||||
|
|
||||||
## Development Environment with Docker
|
# development environment
|
||||||
|
|
||||||
A full development environment can be brought up using Docker, without having to install composer/npm locally
|
A full development environment can be brought up using Docker:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make docker-test
|
composer install
|
||||||
|
yarn install
|
||||||
# **OR** with docker-compose directly
|
docker-compose build
|
||||||
|
docker-compose up
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then go to `http://localhost`. If you're using dnsmasq, the `app` container is listening on `phpvms.test`, or you can add to your `/etc/hosts` file:
|
Then go to `http://localhost`. If you're using dnsmasq, the `app` container is listening on `phpvms.test`, or you can add to your `/etc/hosts` file:
|
||||||
@@ -48,9 +50,7 @@ Then go to `http://localhost`. If you're using dnsmasq, the `app` container is l
|
|||||||
127.0.0.1 phpvms.test
|
127.0.0.1 phpvms.test
|
||||||
```
|
```
|
||||||
|
|
||||||
The `docker-compose.local.yml` overrides the `app` section in `docker-compose.yml`. The standard `docker-compose.yml` can be used if you want to deploy from the image, or as a template for your own Dockerized deployments.
|
## Building JS/CSS assets
|
||||||
|
|
||||||
### Building JS/CSS assets
|
|
||||||
|
|
||||||
Yarn is required, run:
|
Yarn is required, run:
|
||||||
|
|
||||||
|
|||||||
@@ -17,25 +17,25 @@ class AcarsReplay extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected string $apiKey = 'testadminapikey';
|
protected $apiKey = 'testadminapikey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For automatic updates, how many seconds to sleep between updates
|
* For automatic updates, how many seconds to sleep between updates
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected int $sleepTime = 10;
|
protected $sleepTime = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array key == update[callsign]
|
* @var array key == update[callsign]
|
||||||
* value == PIREP ID
|
* value == PIREP ID
|
||||||
*/
|
*/
|
||||||
protected array $pirepList = [];
|
protected $pirepList = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Client
|
* @var Client
|
||||||
*/
|
*/
|
||||||
protected Client $httpClient;
|
protected $httpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of an HTTP client all ready to post
|
* Return an instance of an HTTP client all ready to post
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App;
|
||||||
use App\Contracts\Command;
|
use App\Contracts\Command;
|
||||||
use App\Services\Installer\ConfigService;
|
|
||||||
use App\Services\Installer\SeederService;
|
use App\Services\Installer\SeederService;
|
||||||
use DatabaseSeeder;
|
use DatabaseSeeder;
|
||||||
use Illuminate\Support\Facades\App;
|
use Modules\Installer\Services\ConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the config files
|
* Create the config files
|
||||||
@@ -16,8 +16,8 @@ class CreateConfigs extends Command
|
|||||||
protected $signature = 'phpvms:config {db_host} {db_name} {db_user} {db_pass}';
|
protected $signature = 'phpvms:config {db_host} {db_name} {db_user} {db_pass}';
|
||||||
protected $description = 'Create the config files';
|
protected $description = 'Create the config files';
|
||||||
|
|
||||||
private DatabaseSeeder $databaseSeeder;
|
private $databaseSeeder;
|
||||||
private SeederService $seederSvc;
|
private $seederSvc;
|
||||||
|
|
||||||
public function __construct(DatabaseSeeder $databaseSeeder, SeederService $seederSvc)
|
public function __construct(DatabaseSeeder $databaseSeeder, SeederService $seederSvc)
|
||||||
{
|
{
|
||||||
@@ -81,13 +81,13 @@ class CreateConfigs extends Command
|
|||||||
|
|
||||||
$this->info('Regenerating the config files');
|
$this->info('Regenerating the config files');
|
||||||
$cfgSvc->createConfigFiles([
|
$cfgSvc->createConfigFiles([
|
||||||
'APP_ENV' => 'dev',
|
'APP_ENV' => 'dev',
|
||||||
'SITE_NAME' => $this->argument('name'),
|
'SITE_NAME' => $this->argument('name'),
|
||||||
'DB_CONNECTION' => 'mysql',
|
'DB_CONN' => 'mysql',
|
||||||
'DB_HOST' => $this->argument('db_host'),
|
'DB_HOST' => $this->argument('db_host'),
|
||||||
'DB_DATABASE' => $this->argument('db_name'),
|
'DB_NAME' => $this->argument('db_name'),
|
||||||
'DB_USERNAME' => $this->argument('db_user'),
|
'DB_USER' => $this->argument('db_user'),
|
||||||
'DB_PASSWORD' => $this->argument('db_pass'),
|
'DB_PASS' => $this->argument('db_pass'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('Config files generated!');
|
$this->info('Config files generated!');
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ class CreateDatabase extends Command
|
|||||||
{
|
{
|
||||||
protected $signature = 'database:create {--reset} {--migrate} {--conn=?}';
|
protected $signature = 'database:create {--reset} {--migrate} {--conn=?}';
|
||||||
protected $description = 'Create a database';
|
protected $description = 'Create a database';
|
||||||
|
protected $os;
|
||||||
/**
|
|
||||||
* @var Detector
|
|
||||||
*/
|
|
||||||
protected Detector $os;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateDatabase constructor.
|
* CreateDatabase constructor.
|
||||||
@@ -83,29 +79,21 @@ class CreateDatabase extends Command
|
|||||||
*/
|
*/
|
||||||
protected function create_sqlite($dbkey)
|
protected function create_sqlite($dbkey)
|
||||||
{
|
{
|
||||||
$dbPath = config($dbkey.'database');
|
|
||||||
|
|
||||||
// Skip if running in memory
|
|
||||||
if ($dbPath === ':memory:') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$exec = 'sqlite3';
|
$exec = 'sqlite3';
|
||||||
if ($this->os->isWindowsLike()) {
|
if ($this->os->isWindowsLike()) {
|
||||||
$exec = 'sqlite3.exe';
|
$exec = 'sqlite3.exe';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->option('reset') === true) {
|
if ($this->option('reset') === true) {
|
||||||
if (file_exists($dbPath)) {
|
$cmd = ['rm', '-rf', config($dbkey.'database')];
|
||||||
unlink(config($dbkey.'database'));
|
$this->runCommand($cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($dbPath)) {
|
if (!file_exists(config($dbkey.'database'))) {
|
||||||
$cmd = [
|
$cmd = [
|
||||||
$exec,
|
$exec,
|
||||||
$dbPath,
|
config($dbkey.'database'),
|
||||||
'".exit"',
|
'""',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->runCommand($cmd);
|
$this->runCommand($cmd);
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ class DevCommands extends Command
|
|||||||
{
|
{
|
||||||
protected $signature = 'phpvms {cmd} {param?}';
|
protected $signature = 'phpvms {cmd} {param?}';
|
||||||
protected $description = 'Developer commands';
|
protected $description = 'Developer commands';
|
||||||
|
protected $dbSvc;
|
||||||
protected DatabaseService $dbSvc;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DevCommands constructor.
|
* DevCommands constructor.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Contracts\Command;
|
use App\Contracts\Command;
|
||||||
use App\Services\Installer\ConfigService;
|
use Modules\Installer\Services\ConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a fresh development install
|
* Create a fresh development install
|
||||||
@@ -13,7 +13,7 @@ class DevInstall extends Command
|
|||||||
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
|
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
|
||||||
protected $description = 'Run a developer install and run the sample migration';
|
protected $description = 'Run a developer install and run the sample migration';
|
||||||
|
|
||||||
private \DatabaseSeeder $databaseSeeder;
|
private $databaseSeeder;
|
||||||
|
|
||||||
public function __construct(\DatabaseSeeder $databaseSeeder)
|
public function __construct(\DatabaseSeeder $databaseSeeder)
|
||||||
{
|
{
|
||||||
@@ -79,9 +79,9 @@ class DevInstall extends Command
|
|||||||
|
|
||||||
$this->info('Regenerating the config files');
|
$this->info('Regenerating the config files');
|
||||||
$cfgSvc->createConfigFiles([
|
$cfgSvc->createConfigFiles([
|
||||||
'APP_ENV' => 'dev',
|
'APP_ENV' => 'dev',
|
||||||
'SITE_NAME' => 'phpvms test',
|
'SITE_NAME' => 'phpvms test',
|
||||||
'DB_CONNECTION' => 'sqlite',
|
'DB_CONN' => 'sqlite',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('Config files generated!');
|
$this->info('Config files generated!');
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App;
|
|
||||||
use App\Contracts\Command;
|
|
||||||
|
|
||||||
class EmailTest extends Command
|
|
||||||
{
|
|
||||||
protected $signature = 'phpvms:email-test';
|
|
||||||
protected $description = 'Send a test notification to admins';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dev related commands
|
|
||||||
*
|
|
||||||
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
/** @var App\Notifications\NotificationEventsHandler $eventHandler */
|
|
||||||
$eventHandler = app(App\Notifications\NotificationEventsHandler::class);
|
|
||||||
|
|
||||||
$news = new App\Models\News();
|
|
||||||
$news->user_id = 1;
|
|
||||||
$news->subject = 'Test News';
|
|
||||||
$news->body = 'Test Body';
|
|
||||||
$news->save();
|
|
||||||
|
|
||||||
$newsEvent = new App\Events\NewsAdded($news);
|
|
||||||
$eventHandler->onNewsAdded($newsEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ class ImportCsv extends Command
|
|||||||
protected $signature = 'phpvms:csv-import {type} {file}';
|
protected $signature = 'phpvms:csv-import {type} {file}';
|
||||||
protected $description = 'Import from a CSV file';
|
protected $description = 'Import from a CSV file';
|
||||||
|
|
||||||
private ImportService $importer;
|
private $importer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import constructor.
|
* Import constructor.
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App;
|
|
||||||
use App\Contracts\Command;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ProcessQueue extends Command
|
|
||||||
{
|
|
||||||
protected $signature = 'queue:cron';
|
|
||||||
protected $description = 'Process the queue from a cron job';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the queue tasks
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Artisan::call('queue:work', [
|
|
||||||
//'--sansdaemon' => null,
|
|
||||||
'--stop-when-empty' => null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$jobOutput = trim(Artisan::output());
|
|
||||||
if (!empty($jobOutput)) {
|
|
||||||
Log::info($jobOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
///** @var App\Support\WorkCommand $queueWorker */
|
|
||||||
//$queueWorker = new App\Support\WorkCommand(app('queue.worker'), app('cache.store'));
|
|
||||||
|
|
||||||
//$queueWorker->setInput($queueWorker->createInputFromArguments([]));
|
|
||||||
//$queueWorker->handle();
|
|
||||||
|
|
||||||
/*$output = $this->call('queue:work', [
|
|
||||||
'--stop-when-empty' => null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Log::info($output);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Contracts\Command;
|
|
||||||
use App\Services\Installer\ConfigService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command to rewrite the config files
|
|
||||||
*/
|
|
||||||
class RewriteConfigs extends Command
|
|
||||||
{
|
|
||||||
protected $signature = 'phpvms:rewrite-configs';
|
|
||||||
protected $description = 'Rewrite the config files';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dev related commands
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
/** @var ConfigService $configSvc */
|
|
||||||
$configSvc = app(ConfigService::class);
|
|
||||||
$configSvc->rewriteConfigFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,11 +8,7 @@ use GuzzleHttp\Client;
|
|||||||
class TestApi extends Command
|
class TestApi extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'phpvms:test-api {apikey} {url}';
|
protected $signature = 'phpvms:test-api {apikey} {url}';
|
||||||
|
protected $httpClient;
|
||||||
/**
|
|
||||||
* @var Client
|
|
||||||
*/
|
|
||||||
protected Client $httpClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run dev related commands
|
* Run dev related commands
|
||||||
|
|||||||
@@ -10,14 +10,8 @@ class Version extends Command
|
|||||||
{
|
{
|
||||||
protected $signature = 'phpvms:version {--write} {--base-only} {--write-full-version} {version?}';
|
protected $signature = 'phpvms:version {--write} {--base-only} {--write-full-version} {version?}';
|
||||||
|
|
||||||
/**
|
private $versionSvc;
|
||||||
* @var VersionService
|
|
||||||
*/
|
|
||||||
private VersionService $versionSvc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param VersionService $versionSvc
|
|
||||||
*/
|
|
||||||
public function __construct(VersionService $versionSvc)
|
public function __construct(VersionService $versionSvc)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Contracts\Command;
|
use App\Contracts\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use DB;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,20 +25,6 @@ class YamlExport extends Command
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// A "preset" for exporting the base set of data
|
|
||||||
if ($tables[0] === 'base') {
|
|
||||||
$tables = [
|
|
||||||
'airlines',
|
|
||||||
'aircraft',
|
|
||||||
'subfleets',
|
|
||||||
'subfleet_fare',
|
|
||||||
'subfleet_rank',
|
|
||||||
'bids',
|
|
||||||
'fares',
|
|
||||||
'flights',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$export_tables = [];
|
$export_tables = [];
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
$export_tables[$table] = [];
|
$export_tables[$table] = [];
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ class YamlImport extends Command
|
|||||||
{
|
{
|
||||||
protected $signature = 'phpvms:yaml-import {files*}';
|
protected $signature = 'phpvms:yaml-import {files*}';
|
||||||
protected $description = 'Developer commands';
|
protected $description = 'Developer commands';
|
||||||
|
protected $dbSvc;
|
||||||
/**
|
|
||||||
* @var DatabaseService
|
|
||||||
*/
|
|
||||||
protected DatabaseService $dbSvc;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* YamlImport constructor.
|
* YamlImport constructor.
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This runs any of the cron tasks that are set to run according to the Laravel schedule
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console;
|
|
||||||
|
|
||||||
use App\Console\Cron\FifteenMinute;
|
|
||||||
use App\Console\Cron\FiveMinute;
|
|
||||||
use App\Console\Cron\Hourly;
|
|
||||||
use App\Console\Cron\JobQueue;
|
|
||||||
use App\Console\Cron\Monthly;
|
|
||||||
use App\Console\Cron\Nightly;
|
|
||||||
use App\Console\Cron\ThirtyMinute;
|
|
||||||
use App\Console\Cron\Weekly;
|
|
||||||
use App\Contracts\Command;
|
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
|
||||||
|
|
||||||
class Cron
|
|
||||||
{
|
|
||||||
/** @var Schedule */
|
|
||||||
private $scheduler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string[] The cron tasks which get called/run
|
|
||||||
*/
|
|
||||||
private $cronTasks = [
|
|
||||||
JobQueue::class,
|
|
||||||
FiveMinute::class,
|
|
||||||
FifteenMinute::class,
|
|
||||||
ThirtyMinute::class,
|
|
||||||
Hourly::class,
|
|
||||||
Nightly::class,
|
|
||||||
Weekly::class,
|
|
||||||
Monthly::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Stores the instantiated cron tasks
|
|
||||||
*/
|
|
||||||
private $cronRunners = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Schedule $scheduler
|
|
||||||
*/
|
|
||||||
public function __construct(Schedule $scheduler)
|
|
||||||
{
|
|
||||||
$this->scheduler = $scheduler;
|
|
||||||
foreach ($this->cronTasks as $task) {
|
|
||||||
/** @var Command $cronTask */
|
|
||||||
$cronTask = app($task);
|
|
||||||
$signature = $cronTask->getSignature();
|
|
||||||
|
|
||||||
if (empty($signature)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->cronRunners[$signature] = $cronTask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to figure out which commands are supposed to run right now
|
|
||||||
*
|
|
||||||
* @return array string of tasks that were run
|
|
||||||
*/
|
|
||||||
public function run(): array
|
|
||||||
{
|
|
||||||
$events = $this->scheduler->dueEvents(app());
|
|
||||||
if (empty($events)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$run = [];
|
|
||||||
|
|
||||||
/** @var \Illuminate\Console\Scheduling\Event $event */
|
|
||||||
foreach ($events as $event) {
|
|
||||||
foreach ($this->cronRunners as $signature => $task) {
|
|
||||||
if (!str_contains($event->command, $signature)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$task->callEvent();
|
|
||||||
$run[] = $signature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $run;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Cron;
|
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
|
||||||
use App\Events\CronFifteenMinute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The actual cron tasks are in app/Cron
|
|
||||||
*/
|
|
||||||
class FifteenMinute extends CronCommand
|
|
||||||
{
|
|
||||||
protected $signature = 'cron:fifteen';
|
|
||||||
protected $description = 'Run the 15 minute cron tasks';
|
|
||||||
protected $schedule;
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
$this->callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronFifteenMinute());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Cron;
|
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
|
||||||
use App\Events\CronFiveMinute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This just calls the CronNightly event, so all of the
|
|
||||||
* listeners, etc can just be called to run those tasks
|
|
||||||
*
|
|
||||||
* The actual cron tasks are in app/Cron
|
|
||||||
*/
|
|
||||||
class FiveMinute extends CronCommand
|
|
||||||
{
|
|
||||||
protected $signature = 'cron:five';
|
|
||||||
protected $description = 'Run the 5 minute cron tasks';
|
|
||||||
protected $schedule;
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
$this->callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronFiveMinute());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Console\Cron;
|
namespace App\Console\Cron;
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
use App\Contracts\Command;
|
||||||
use App\Events\CronHourly;
|
use App\Events\CronHourly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This just calls the CronHourly event, so all of the
|
* This just calls the CronHourly event, so all of the
|
||||||
* listeners, etc can just be called to run those tasks
|
* listeners, etc can just be called to run those tasks
|
||||||
*/
|
*/
|
||||||
class Hourly extends CronCommand
|
class Hourly extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'cron:hourly';
|
protected $signature = 'cron:hourly';
|
||||||
protected $description = 'Run the hourly cron tasks';
|
protected $description = 'Run the hourly cron tasks';
|
||||||
@@ -17,11 +17,7 @@ class Hourly extends CronCommand
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$this->callEvent();
|
$this->redirectLoggingToFile('cron');
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronHourly());
|
event(new CronHourly());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Cron;
|
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This just calls the CronHourly event, so all of the
|
|
||||||
* listeners, etc can just be called to run those tasks
|
|
||||||
*/
|
|
||||||
class JobQueue extends CronCommand
|
|
||||||
{
|
|
||||||
protected $signature = 'cron:queue';
|
|
||||||
protected $description = 'Run the cron queue tasks';
|
|
||||||
protected $schedule;
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
$this->callEvent();
|
|
||||||
|
|
||||||
$queueOutput = trim(Artisan::output());
|
|
||||||
if (!empty($queueOutput)) {
|
|
||||||
$this->info($queueOutput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
Artisan::call('queue:cron');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Cron;
|
namespace App\Console\Cron;
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
use App\Contracts\Command;
|
||||||
use App\Events\CronMonthly;
|
use App\Events\CronMonthly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +11,7 @@ use App\Events\CronMonthly;
|
|||||||
*
|
*
|
||||||
* The actual cron tasks are in app/Cron
|
* The actual cron tasks are in app/Cron
|
||||||
*/
|
*/
|
||||||
class Monthly extends CronCommand
|
class Monthly extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'cron:monthly';
|
protected $signature = 'cron:monthly';
|
||||||
protected $description = 'Run the monthly cron tasks';
|
protected $description = 'Run the monthly cron tasks';
|
||||||
@@ -19,11 +19,7 @@ class Monthly extends CronCommand
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$this->callEvent();
|
$this->redirectLoggingToFile('cron');
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronMonthly());
|
event(new CronMonthly());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Cron;
|
namespace App\Console\Cron;
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
use App\Contracts\Command;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +11,7 @@ use App\Events\CronNightly;
|
|||||||
*
|
*
|
||||||
* The actual cron tasks are in app/Cron
|
* The actual cron tasks are in app/Cron
|
||||||
*/
|
*/
|
||||||
class Nightly extends CronCommand
|
class Nightly extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'cron:nightly';
|
protected $signature = 'cron:nightly';
|
||||||
protected $description = 'Run the nightly cron tasks';
|
protected $description = 'Run the nightly cron tasks';
|
||||||
@@ -19,11 +19,7 @@ class Nightly extends CronCommand
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$this->callEvent();
|
$this->redirectLoggingToFile('cron');
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronNightly());
|
event(new CronNightly());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Cron;
|
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
|
||||||
use App\Events\CronThirtyMinute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The actual cron tasks are in app/Cron
|
|
||||||
*/
|
|
||||||
class ThirtyMinute extends CronCommand
|
|
||||||
{
|
|
||||||
protected $signature = 'cron:thirty';
|
|
||||||
protected $description = 'Run the 30 minute cron tasks';
|
|
||||||
protected $schedule;
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
$this->callEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronThirtyMinute());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Cron;
|
namespace App\Console\Cron;
|
||||||
|
|
||||||
use App\Contracts\CronCommand;
|
use App\Contracts\Command;
|
||||||
use App\Events\CronWeekly;
|
use App\Events\CronWeekly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +11,7 @@ use App\Events\CronWeekly;
|
|||||||
*
|
*
|
||||||
* The actual cron tasks are in app/Cron
|
* The actual cron tasks are in app/Cron
|
||||||
*/
|
*/
|
||||||
class Weekly extends CronCommand
|
class Weekly extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'cron:weekly';
|
protected $signature = 'cron:weekly';
|
||||||
protected $description = 'Run the weekly cron tasks';
|
protected $description = 'Run the weekly cron tasks';
|
||||||
@@ -19,11 +19,7 @@ class Weekly extends CronCommand
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$this->callEvent();
|
$this->redirectLoggingToFile('cron');
|
||||||
}
|
|
||||||
|
|
||||||
public function callEvent()
|
|
||||||
{
|
|
||||||
event(new CronWeekly());
|
event(new CronWeekly());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use App\Console\Cron\FifteenMinute;
|
|
||||||
use App\Console\Cron\FiveMinute;
|
|
||||||
use App\Console\Cron\Hourly;
|
use App\Console\Cron\Hourly;
|
||||||
use App\Console\Cron\JobQueue;
|
|
||||||
use App\Console\Cron\Monthly;
|
use App\Console\Cron\Monthly;
|
||||||
use App\Console\Cron\Nightly;
|
use App\Console\Cron\Nightly;
|
||||||
use App\Console\Cron\ThirtyMinute;
|
|
||||||
use App\Console\Cron\Weekly;
|
use App\Console\Cron\Weekly;
|
||||||
use App\Services\CronService;
|
use App\Services\CronService;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
@@ -17,11 +13,7 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Define the application's command schedule. How this works... according to the command
|
* Define the application's command schedule.
|
||||||
* time, an event gets send out with the appropriate time (e.g, hourly sends an hourly event)
|
|
||||||
*
|
|
||||||
* Then the CronServiceProvider has the list of cronjobs which then run according to the events
|
|
||||||
* and then calls those at the proper times.
|
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
*
|
*
|
||||||
@@ -29,32 +21,16 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule): void
|
protected function schedule(Schedule $schedule): void
|
||||||
{
|
{
|
||||||
// If not using the queue worker then run those via cron
|
|
||||||
if (!config('queue.worker', false)) {
|
|
||||||
$schedule->command(JobQueue::class)
|
|
||||||
->everyMinute()
|
|
||||||
->withoutOverlapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: IF MORE TASKS ARE ADDED, THEY ALSO MUST BE ADDED TO THE CRON.PHP
|
|
||||||
*/
|
|
||||||
$schedule->command(FiveMinute::class)->everyFiveMinutes();
|
|
||||||
$schedule->command(FifteenMinute::class)->everyFifteenMinutes();
|
|
||||||
$schedule->command(ThirtyMinute::class)->everyThirtyMinutes();
|
|
||||||
$schedule->command(Nightly::class)->dailyAt('01:00');
|
$schedule->command(Nightly::class)->dailyAt('01:00');
|
||||||
$schedule->command(Hourly::class)->hourly();
|
|
||||||
$schedule->command(Weekly::class)->weeklyOn(0);
|
$schedule->command(Weekly::class)->weeklyOn(0);
|
||||||
$schedule->command(Monthly::class)->monthlyOn(1);
|
$schedule->command(Monthly::class)->monthlyOn(1);
|
||||||
|
$schedule->command(Hourly::class)->hourly();
|
||||||
|
|
||||||
// When spatie-backups runs
|
// When spatie-backups runs
|
||||||
/*if (config('backup.backup.enabled', false) === true) {
|
$schedule->command('backup:clean')->daily()->at('01:00');
|
||||||
$schedule->command('backup:clean')->daily()->at('01:00');
|
$schedule->command('backup:run')->daily()->at('02:00');
|
||||||
$schedule->command('backup:run')->daily()->at('02:00');
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Update the last time the cron was run
|
// Update the last time the cron was run
|
||||||
/** @var CronService $cronSvc */
|
|
||||||
$cronSvc = app(CronService::class);
|
$cronSvc = app(CronService::class);
|
||||||
$cronSvc->updateLastRunTime();
|
$cronSvc->updateLastRunTime();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,8 @@ abstract class Award
|
|||||||
* You don't really need to mess with anything below here
|
* You don't really need to mess with anything below here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @var \App\Models\Award|null */
|
protected $award;
|
||||||
protected ?AwardModel $award;
|
protected $user;
|
||||||
|
|
||||||
/** @var \App\Models\User|null */
|
|
||||||
protected ?User $user;
|
|
||||||
|
|
||||||
public function __construct(AwardModel $award = null, User $user = null)
|
public function __construct(AwardModel $award = null, User $user = null)
|
||||||
{
|
{
|
||||||
@@ -69,9 +66,9 @@ abstract class Award
|
|||||||
/**
|
/**
|
||||||
* Add the award to this user, if they don't already have it
|
* Add the award to this user, if they don't already have it
|
||||||
*
|
*
|
||||||
* @return bool|UserAward|null
|
* @return bool|UserAward
|
||||||
*/
|
*/
|
||||||
protected function addAward(): bool|UserAward|null
|
protected function addAward()
|
||||||
{
|
{
|
||||||
$w = [
|
$w = [
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use function is_array;
|
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,19 +23,9 @@ abstract class Command extends \Illuminate\Console\Command
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
// Running in the console but not in the tests
|
// Running in the console but not in the tests
|
||||||
/*if (app()->runningInConsole() && env('APP_ENV') !== 'testing') {
|
if (app()->runningInConsole() && env('APP_ENV') !== 'testing') {
|
||||||
$this->redirectLoggingToFile('stdout');
|
$this->redirectLoggingToFile('stdout');
|
||||||
}*/
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the signature of the command
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getSignature(): string
|
|
||||||
{
|
|
||||||
return $this->signature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,9 +82,9 @@ abstract class Command extends \Illuminate\Console\Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $cmd
|
* @param $cmd
|
||||||
* @param bool $return
|
* @param bool $return
|
||||||
* @param mixed $verbose
|
* @param mixed $verbose
|
||||||
*
|
*
|
||||||
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
||||||
* @throws \Symfony\Component\Process\Exception\LogicException
|
* @throws \Symfony\Component\Process\Exception\LogicException
|
||||||
@@ -104,16 +93,16 @@ abstract class Command extends \Illuminate\Console\Command
|
|||||||
*/
|
*/
|
||||||
public function runCommand($cmd, $return = false, $verbose = true): string
|
public function runCommand($cmd, $return = false, $verbose = true): string
|
||||||
{
|
{
|
||||||
if (is_array($cmd)) {
|
if (\is_array($cmd)) {
|
||||||
$cmd = implode(' ', $cmd);
|
$cmd = implode(' ', $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->info('Running '.$cmd);
|
$this->info('Running "'.$cmd.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
$val = '';
|
$val = '';
|
||||||
$process = Process::fromShellCommandline($cmd);
|
$process = new Process($cmd);
|
||||||
$process->run(function ($type, $buffer) use ($return, &$val) {
|
$process->run(function ($type, $buffer) use ($return, &$val) {
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$val .= $buffer;
|
$val .= $buffer;
|
||||||
|
|||||||
@@ -84,21 +84,19 @@ abstract class Controller extends \Illuminate\Routing\Controller
|
|||||||
*
|
*
|
||||||
* @param $message
|
* @param $message
|
||||||
* @param null|mixed $count
|
* @param null|mixed $count
|
||||||
* @param mixed $attrs
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function message($message, $count = null, $attrs = [])
|
public function message($message, $count = null)
|
||||||
{
|
{
|
||||||
$ret = [
|
$attrs = [
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'attrs' => $attrs,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($count !== null) {
|
if ($count !== null) {
|
||||||
$ret['count'] = $count;
|
$attrs['count'] = $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($ret);
|
return response()->json($attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contracts;
|
|
||||||
|
|
||||||
abstract class CronCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
abstract public function callEvent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adjust the logging depending on where we're running from
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->redirectLoggingToFile('cron');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,14 +7,14 @@ namespace App\Contracts;
|
|||||||
*/
|
*/
|
||||||
abstract class Enum
|
abstract class Enum
|
||||||
{
|
{
|
||||||
protected static array $cache = [];
|
protected static $cache = [];
|
||||||
protected static array $codes = [];
|
protected static $codes = [];
|
||||||
protected static array $labels = [];
|
protected static $labels = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected int $value;
|
protected $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of this Enum
|
* Create an instance of this Enum
|
||||||
@@ -29,9 +29,9 @@ abstract class Enum
|
|||||||
/**
|
/**
|
||||||
* Return the value that's been set if this is an instance
|
* Return the value that's been set if this is an instance
|
||||||
*
|
*
|
||||||
* @return int|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
final public function getValue(): ?int
|
final public function getValue()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
@@ -41,9 +41,9 @@ abstract class Enum
|
|||||||
*
|
*
|
||||||
* @param $value
|
* @param $value
|
||||||
*
|
*
|
||||||
* @return string
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
final public static function label($value): string
|
final public static function label($value)
|
||||||
{
|
{
|
||||||
if (isset(static::$labels[$value])) {
|
if (isset(static::$labels[$value])) {
|
||||||
$val = static::$labels[$value];
|
$val = static::$labels[$value];
|
||||||
@@ -53,8 +53,6 @@ abstract class Enum
|
|||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,11 +87,11 @@ abstract class Enum
|
|||||||
*
|
*
|
||||||
* @return false|int|string
|
* @return false|int|string
|
||||||
*/
|
*/
|
||||||
public static function convertToCode($value): bool|int|string|null
|
public static function convertToCode($value)
|
||||||
{
|
{
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
if (!array_key_exists($value, static::$codes)) {
|
if (!array_key_exists($value, static::$codes)) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::$codes[$value];
|
return static::$codes[$value];
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contracts;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class Event
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
use SerializesModels;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contracts;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory as EloquentFactory;
|
|
||||||
|
|
||||||
abstract class Factory extends EloquentFactory
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use App\Models\Airline;
|
use App\Models\Airline;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Log;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common functionality used across all of the importers
|
* Common functionality used across all of the importers
|
||||||
@@ -51,9 +51,9 @@ class ImportExport
|
|||||||
*
|
*
|
||||||
* @param $code
|
* @param $code
|
||||||
*
|
*
|
||||||
* @return Airline
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
*/
|
*/
|
||||||
public function getAirline($code): Airline
|
public function getAirline($code)
|
||||||
{
|
{
|
||||||
$airline = Airline::firstOrCreate([
|
$airline = Airline::firstOrCreate([
|
||||||
'icao' => $code,
|
'icao' => $code,
|
||||||
@@ -166,36 +166,10 @@ class ImportExport
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($split_values[0], '?') !== false) {
|
|
||||||
// This contains the query string, which turns it into a multi-level array
|
|
||||||
$query_str = explode('?', $split_values[0]);
|
|
||||||
$parent = trim($query_str[0]);
|
|
||||||
|
|
||||||
$children = [];
|
|
||||||
$kvp = explode('&', trim($query_str[1]));
|
|
||||||
foreach ($kvp as $items) {
|
|
||||||
if (!$items) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->kvpToArray($items, $children);
|
|
||||||
}
|
|
||||||
|
|
||||||
$ret[$parent] = $children;
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is not a query string, return it back untouched
|
|
||||||
return [$split_values[0]];
|
return [$split_values[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($split_values as $value) {
|
foreach ($split_values as $value) {
|
||||||
$value = trim($value);
|
|
||||||
if ($value === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This isn't in the query string format, so it's
|
// This isn't in the query string format, so it's
|
||||||
// just a straight key-value pair set
|
// just a straight key-value pair set
|
||||||
if (strpos($value, '?') === false) {
|
if (strpos($value, '?') === false) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ abstract class Listener
|
|||||||
public function subscribe(Dispatcher $events): void
|
public function subscribe(Dispatcher $events): void
|
||||||
{
|
{
|
||||||
foreach (static::$callbacks as $klass => $cb) {
|
foreach (static::$callbacks as $klass => $cb) {
|
||||||
$events->listen($klass, static::class.'@'.$cb);
|
$events->listen($klass, get_class($this).'@'.$cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,24 +12,13 @@ abstract class Metar
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
||||||
* since this shouldn't be directly called. Call `metar($icao)`. If not implemented,
|
* since this shouldn't be directly called. Call `get_metar($icao)` instead
|
||||||
* return a blank string
|
|
||||||
*
|
*
|
||||||
* @param $icao
|
* @param $icao
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract protected function get_metar($icao): string;
|
abstract protected function metar($icao): string;
|
||||||
|
|
||||||
/**
|
|
||||||
* Implement retrieving the TAF - return the string. Call `taf($icao)`. If not implemented,
|
|
||||||
* return a blank string
|
|
||||||
*
|
|
||||||
* @param $icao
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
abstract protected function get_taf($icao): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the METAR, wrap in caching
|
* Download the METAR, wrap in caching
|
||||||
@@ -38,9 +27,9 @@ abstract class Metar
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function metar($icao): string
|
public function get_metar($icao): string
|
||||||
{
|
{
|
||||||
$cache = config('cache.keys.METAR_WEATHER_LOOKUP');
|
$cache = config('cache.keys.WEATHER_LOOKUP');
|
||||||
$key = $cache['key'].$icao;
|
$key = $cache['key'].$icao;
|
||||||
|
|
||||||
if (Cache::has($key)) {
|
if (Cache::has($key)) {
|
||||||
@@ -51,7 +40,7 @@ abstract class Metar
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$raw_metar = $this->get_metar($icao);
|
$raw_metar = $this->metar($icao);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
||||||
return '';
|
return '';
|
||||||
@@ -63,37 +52,4 @@ abstract class Metar
|
|||||||
|
|
||||||
return $raw_metar;
|
return $raw_metar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Download the TAF, wrap in caching
|
|
||||||
*
|
|
||||||
* @param $icao
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function taf($icao): string
|
|
||||||
{
|
|
||||||
$cache = config('cache.keys.TAF_WEATHER_LOOKUP');
|
|
||||||
$key = $cache['key'].$icao;
|
|
||||||
|
|
||||||
if (Cache::has($key)) {
|
|
||||||
$taf = Cache::get($key);
|
|
||||||
if ($taf !== '') {
|
|
||||||
return $taf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$taf = $this->get_taf($icao);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Log::error('Error getting TAF: '.$e->getMessage(), $e->getTrace());
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($taf !== '') {
|
|
||||||
Cache::put($key, $taf, $cache['time']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $taf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,8 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use App\Support\Database;
|
use App\Support\Database;
|
||||||
use Exception;
|
use DB;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Migration
|
* Class Migration
|
||||||
@@ -28,29 +25,6 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a module and enable it
|
|
||||||
*
|
|
||||||
* @param array $attrs
|
|
||||||
*/
|
|
||||||
public function addModule(array $attrs)
|
|
||||||
{
|
|
||||||
$module = array_merge([
|
|
||||||
'enabled' => true,
|
|
||||||
'created_at' => DB::raw('NOW()'),
|
|
||||||
'updated_at' => DB::raw('NOW()'),
|
|
||||||
], $attrs);
|
|
||||||
|
|
||||||
try {
|
|
||||||
DB::table('modules')->insert($module);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// setting already exists, just ignore it
|
|
||||||
if ($e->getCode() === 23000) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seed a YAML file into the database
|
* Seed a YAML file into the database
|
||||||
*
|
*
|
||||||
@@ -61,7 +35,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
|||||||
try {
|
try {
|
||||||
$path = base_path($file);
|
$path = base_path($file);
|
||||||
Database::seed_from_yaml_file($path, false);
|
Database::seed_from_yaml_file($path, false);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Unable to load '.$file.' file');
|
Log::error('Unable to load '.$file.' file');
|
||||||
Log::error($e);
|
Log::error($e);
|
||||||
}
|
}
|
||||||
@@ -78,7 +52,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
|||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
try {
|
try {
|
||||||
DB::table($table)->insert($row);
|
DB::table($table)->insert($row);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// setting already exists, just ignore it
|
// setting already exists, just ignore it
|
||||||
if ($e->getCode() === 23000) {
|
if ($e->getCode() === 23000) {
|
||||||
continue;
|
continue;
|
||||||
@@ -86,22 +60,4 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an award from the migrations (for example, if you're adding an award module)
|
|
||||||
*
|
|
||||||
* @param array $award See \App\Models\Awardv
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
|
||||||
*/
|
|
||||||
public function addAward(array $award)
|
|
||||||
{
|
|
||||||
$validator = Validator::make($award, \App\Models\Award::$rules);
|
|
||||||
if ($validator->fails()) {
|
|
||||||
throw new ValidationException($validator);
|
|
||||||
}
|
|
||||||
|
|
||||||
$awardModel = new \App\Models\Award($award);
|
|
||||||
$awardModel->save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contracts\Modules;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for module service providers
|
|
||||||
* Add-on module service providers must extend this class. Docs on Service Providers:
|
|
||||||
* https://laravel.com/docs/7.x/providers
|
|
||||||
*
|
|
||||||
* For a sample service provider, view the sample module one:
|
|
||||||
* https://github.com/nabeelio/phpvms-module/blob/master/Providers/SampleServiceProvider.php
|
|
||||||
*/
|
|
||||||
abstract class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A boot method is required, even if it doesn't do anything.
|
|
||||||
* https://laravel.com/docs/7.x/providers#the-boot-method
|
|
||||||
*
|
|
||||||
* This is normally where you'd register the routes or other startup tasks for your module
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is required to register the links in either the public or admin toolbar
|
|
||||||
* For example, adding a frontend link:
|
|
||||||
*
|
|
||||||
* $this->moduleSvc->addFrontendLink('Sample', '/sample', '', $logged_in=true);
|
|
||||||
*
|
|
||||||
* Or an admin link:
|
|
||||||
*
|
|
||||||
* $this->moduleSvc->addAdminLink('Sample', '/admin/sample');
|
|
||||||
*/
|
|
||||||
public function registerLinks(): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deferred providers:
|
|
||||||
* https://laravel.com/docs/7.x/providers#deferred-providers
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function provides(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
use function is_array;
|
|
||||||
use Prettus\Repository\Eloquent\BaseRepository;
|
use Prettus\Repository\Eloquent\BaseRepository;
|
||||||
use Prettus\Repository\Exceptions\RepositoryException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin BaseRepository
|
* @mixin \Prettus\Repository\Eloquent\BaseRepository
|
||||||
*/
|
*/
|
||||||
abstract class Repository extends BaseRepository
|
abstract class Repository extends BaseRepository
|
||||||
{
|
{
|
||||||
@@ -23,8 +20,8 @@ abstract class Repository extends BaseRepository
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->find($id, $columns);
|
return $this->find($id, $columns);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +32,11 @@ abstract class Repository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function validate($values)
|
public function validate($values)
|
||||||
{
|
{
|
||||||
$validator = Validator::make($values, $this->model()->rules);
|
$validator = Validator::make(
|
||||||
|
$values,
|
||||||
|
$this->model()->rules
|
||||||
|
);
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return $validator->messages();
|
return $validator->messages();
|
||||||
}
|
}
|
||||||
@@ -49,8 +50,6 @@ abstract class Repository extends BaseRepository
|
|||||||
* @param int $count
|
* @param int $count
|
||||||
* @param string $sort_by created_at (default) or updated_at
|
* @param string $sort_by created_at (default) or updated_at
|
||||||
*
|
*
|
||||||
* @throws RepositoryException
|
|
||||||
*
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function recent($count = null, $sort_by = 'created_at')
|
public function recent($count = null, $sort_by = 'created_at')
|
||||||
@@ -72,7 +71,7 @@ abstract class Repository extends BaseRepository
|
|||||||
return $this->scopeQuery(function ($query) use ($where, $sort_by, $order_by) {
|
return $this->scopeQuery(function ($query) use ($where, $sort_by, $order_by) {
|
||||||
$q = $query->where($where);
|
$q = $query->where($where);
|
||||||
// See if there are multi-column sorts
|
// See if there are multi-column sorts
|
||||||
if (is_array($sort_by)) {
|
if (\is_array($sort_by)) {
|
||||||
foreach ($sort_by as $key => $sort) {
|
foreach ($sort_by as $key => $sort) {
|
||||||
$q = $q->orderBy($key, $sort);
|
$q = $q->orderBy($key, $sort);
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,7 @@ abstract class Repository extends BaseRepository
|
|||||||
return $this->scopeQuery(function ($query) use ($col, $values, $sort_by, $order_by) {
|
return $this->scopeQuery(function ($query) use ($col, $values, $sort_by, $order_by) {
|
||||||
$q = $query->whereNotIn($col, $values);
|
$q = $query->whereNotIn($col, $values);
|
||||||
// See if there are multi-column sorts
|
// See if there are multi-column sorts
|
||||||
if (is_array($sort_by)) {
|
if (\is_array($sort_by)) {
|
||||||
foreach ($sort_by as $key => $sort) {
|
foreach ($sort_by as $key => $sort) {
|
||||||
$q = $q->orderBy($key, $sort);
|
$q = $q->orderBy($key, $sort);
|
||||||
}
|
}
|
||||||
@@ -119,7 +118,7 @@ abstract class Repository extends BaseRepository
|
|||||||
* @param array $columns
|
* @param array $columns
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*
|
*
|
||||||
* @throws RepositoryException
|
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -133,10 +132,7 @@ abstract class Repository extends BaseRepository
|
|||||||
$page = (int) request()->query('page', 1);
|
$page = (int) request()->query('page', 1);
|
||||||
|
|
||||||
$results = $this->model->{$method}($limit, $columns, 'page', $page);
|
$results = $this->model->{$method}($limit, $columns, 'page', $page);
|
||||||
|
$results->appends(app('request')->query());
|
||||||
$qs = request()->except(['page', 'user']);
|
|
||||||
$results->appends($qs);
|
|
||||||
|
|
||||||
$this->resetModel();
|
$this->resetModel();
|
||||||
|
|
||||||
return $this->parserResult($results);
|
return $this->parserResult($results);
|
||||||
|
|||||||
@@ -2,15 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use App\Support\Resources\CustomAnonymousResourceCollection;
|
|
||||||
use App\Support\Resources\CustomPaginatedResourceResponse;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
use Illuminate\Pagination\AbstractPaginator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for a resource/response
|
* Base class for a resource/response
|
||||||
*/
|
*/
|
||||||
class Resource extends JsonResource
|
class Resource extends \Illuminate\Http\Resources\Json\Resource
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Iterate through the list of $fields and check if they're a "Unit"
|
* Iterate through the list of $fields and check if they're a "Unit"
|
||||||
@@ -29,28 +24,4 @@ class Resource extends JsonResource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Customize the response to exclude all the extra data that isn't used. Based on:
|
|
||||||
* https://gist.github.com/derekphilipau/4be52164a69ce487dcd0673656d280da
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
public function toResponse($request)
|
|
||||||
{
|
|
||||||
return $this->resource instanceof AbstractPaginator
|
|
||||||
? (new CustomPaginatedResourceResponse($this))->toResponse($request)
|
|
||||||
: parent::toResponse($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function collection($resource)
|
|
||||||
{
|
|
||||||
return tap(new CustomAnonymousResourceCollection($resource, static::class), function ($collection) {
|
|
||||||
if (property_exists(static::class, 'preserveKeys')) {
|
|
||||||
$collection->preserveKeys = (new static([]))->preserveKeys === true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Contracts;
|
namespace App\Contracts;
|
||||||
|
|
||||||
use ArrayAccess;
|
use ArrayAccess;
|
||||||
|
use PhpUnitsOfMeasure\Exception\UnknownUnitOfMeasure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract unit wrapper
|
* Abstract unit wrapper
|
||||||
@@ -10,89 +11,45 @@ use ArrayAccess;
|
|||||||
class Unit implements ArrayAccess
|
class Unit implements ArrayAccess
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The localized unit the user wants it displayed in
|
* The unit this is kept as
|
||||||
*/
|
*/
|
||||||
public string $localUnit;
|
public $unit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unit that this value is stored in locally
|
* All of the units of this class
|
||||||
*/
|
*/
|
||||||
public string $internalUnit;
|
public $units;
|
||||||
|
|
||||||
/**
|
|
||||||
* All of the units of this class which are reported in an API response
|
|
||||||
*/
|
|
||||||
public array $units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds an instance of the PhpUnit type
|
* Holds an instance of the PhpUnit type
|
||||||
|
*
|
||||||
|
* @var \PhpUnitsOfMeasure\AbstractPhysicalQuantity
|
||||||
*/
|
*/
|
||||||
protected mixed $instance;
|
protected $instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Units that are included as part of the REST response
|
* Units that are included as part of the REST response
|
||||||
*/
|
*/
|
||||||
public array $responseUnits = [];
|
public $responseUnits = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method for creating a new unit type
|
* @return mixed
|
||||||
*
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $unit
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @return Unit
|
|
||||||
*/
|
*/
|
||||||
public static function make(mixed $value, string $unit): self
|
public function value()
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
return $this->__toString();
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new static($value, $unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value in an internal format
|
|
||||||
*
|
|
||||||
* @param int|null $round Optional value to round to
|
|
||||||
*
|
|
||||||
* @return float|null
|
|
||||||
*/
|
|
||||||
public function internal(?int $round = null): ?float
|
|
||||||
{
|
|
||||||
return $this->toUnit($this->internalUnit, $round);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value in the localized format
|
|
||||||
*
|
|
||||||
* @param int|null $round Optional value to round to
|
|
||||||
*
|
|
||||||
* @return float|null
|
|
||||||
*/
|
|
||||||
public function local(?int $round = null): ?float
|
|
||||||
{
|
|
||||||
return $this->toUnit($this->localUnit, $round);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just call toUnit() on the PhpUnitOfMeasure instance
|
* Just call toUnit() on the PhpUnitOfMeasure instance
|
||||||
*
|
*
|
||||||
* @param string $unit
|
* @param string $unit
|
||||||
* @param int|null $round Optional value to round to
|
|
||||||
*
|
*
|
||||||
* @return float|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function toUnit(string $unit, ?int $round = null): ?float
|
public function toUnit($unit)
|
||||||
{
|
{
|
||||||
$val = $this->instance->toUnit($unit);
|
return $this->instance->toUnit($unit);
|
||||||
if ($round === null) {
|
|
||||||
return $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return round($val, $round);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +59,7 @@ class Unit implements ArrayAccess
|
|||||||
{
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
foreach ($this->responseUnits as $unit) {
|
foreach ($this->responseUnits as $unit) {
|
||||||
$response[$unit] = round($this->instance->toUnit($unit), 2);
|
$response[$unit] = $this[$unit] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@@ -115,7 +72,7 @@ class Unit implements ArrayAccess
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset): bool
|
public function offsetExists($offset)
|
||||||
{
|
{
|
||||||
return $this->offsetGet($offset) !== null;
|
return $this->offsetGet($offset) !== null;
|
||||||
}
|
}
|
||||||
@@ -123,15 +80,19 @@ class Unit implements ArrayAccess
|
|||||||
/**
|
/**
|
||||||
* Implements ArrayAccess
|
* Implements ArrayAccess
|
||||||
*
|
*
|
||||||
* @param $unit
|
* @param $offset
|
||||||
*
|
*
|
||||||
* @return float|null
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function offsetGet($unit): ?float
|
public function offsetGet($offset)
|
||||||
{
|
{
|
||||||
$value = $this->instance->toUnit($unit);
|
try {
|
||||||
if (!$value) {
|
$value = $this->instance->toUnit($offset);
|
||||||
return null;
|
if (!$value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (UnknownUnitOfMeasure $e) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return round($value, 2);
|
return round($value, 2);
|
||||||
@@ -163,6 +124,6 @@ class Unit implements ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return (string) $this->offsetGet($this->localUnit);
|
return (string) $this->offsetGet($this->unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Cron\Hourly;
|
|
||||||
|
|
||||||
use App\Contracts\Listener;
|
|
||||||
use App\Events\CronHourly;
|
|
||||||
use App\Models\Enums\PirepState;
|
|
||||||
use App\Models\Enums\PirepStatus;
|
|
||||||
use App\Models\Pirep;
|
|
||||||
use App\Services\PirepService;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove cancelled/deleted PIREPs. Look for PIREPs that were created before the setting time
|
|
||||||
* (e.g, 12 hours ago) and are marked with the
|
|
||||||
*/
|
|
||||||
class DeletePireps extends Listener
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Delete old rejected PIREPs
|
|
||||||
*
|
|
||||||
* @param CronHourly $event
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function handle(CronHourly $event): void
|
|
||||||
{
|
|
||||||
$this->deletePireps(setting('pireps.delete_rejected_hours'), PirepState::REJECTED);
|
|
||||||
$this->deletePireps(setting('pireps.delete_cancelled_hours'), PirepState::CANCELLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look for and delete PIREPs which match the criteria
|
|
||||||
*
|
|
||||||
* @param int $expire_time_hours The time in hours to look for PIREPs
|
|
||||||
* @param int $state The PirepState enum value
|
|
||||||
*/
|
|
||||||
protected function deletePireps(int $expire_time_hours, int $state)
|
|
||||||
{
|
|
||||||
$dt = Carbon::now('UTC')->subHours($expire_time_hours);
|
|
||||||
$pireps = Pirep::where('created_at', '<', $dt)
|
|
||||||
->where(['state' => $state])
|
|
||||||
->where('status', '<>', PirepStatus::PAUSED)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
/** @var PirepService $pirepSvc */
|
|
||||||
$pirepSvc = app(PirepService::class);
|
|
||||||
|
|
||||||
/** @var Pirep $pirep */
|
|
||||||
foreach ($pireps as $pirep) {
|
|
||||||
Log::info('Cron: Deleting PIREP id='.$pirep->id.', state='.PirepState::label($state));
|
|
||||||
$pirepSvc->delete($pirep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@ class RemoveExpiredBids extends Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = Carbon::now('UTC')->subHours(setting('bids.expire_time'));
|
$date = Carbon::now()->subHours(setting('bids.expire_time'));
|
||||||
Bid::where('created_at', '<', $date)->delete();
|
Bid::whereDate('created_at', '<', $date)->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,9 @@ namespace App\Cron\Hourly;
|
|||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronHourly;
|
use App\Events\CronHourly;
|
||||||
use App\Events\PirepCancelled;
|
|
||||||
use App\Models\Enums\PirepState;
|
use App\Models\Enums\PirepState;
|
||||||
use App\Models\Enums\PirepStatus;
|
|
||||||
use App\Models\Pirep;
|
use App\Models\Pirep;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove expired live flights
|
* Remove expired live flights
|
||||||
@@ -29,16 +26,9 @@ class RemoveExpiredLiveFlights extends Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = Carbon::now('UTC')->subHours(setting('acars.live_time'));
|
$date = Carbon::now()->subHours(setting('acars.live_time'));
|
||||||
$pireps = Pirep::where('updated_at', '<', $date)
|
Pirep::whereDate('updated_at', '<', $date)
|
||||||
->where('state', PirepState::IN_PROGRESS)
|
->where('state', PirepState::IN_PROGRESS)
|
||||||
->where('status', '<>', PirepStatus::PAUSED)
|
->delete();
|
||||||
->get();
|
|
||||||
|
|
||||||
foreach ($pireps as $pirep) {
|
|
||||||
event(new PirepCancelled($pirep));
|
|
||||||
Log::info('Cron: Deleting Expired Live PIREP id='.$pirep->id.', state='.PirepState::label($pirep->state));
|
|
||||||
$pirep->delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ use App\Contracts\Listener;
|
|||||||
use App\Events\CronMonthly;
|
use App\Events\CronMonthly;
|
||||||
use App\Models\Enums\ExpenseType;
|
use App\Models\Enums\ExpenseType;
|
||||||
use App\Services\Finance\RecurringFinanceService;
|
use App\Services\Finance\RecurringFinanceService;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through and apply any finances that are daily
|
* Go through and apply any finances that are daily
|
||||||
*/
|
*/
|
||||||
class ApplyExpenses extends Listener
|
class ApplyExpenses extends Listener
|
||||||
{
|
{
|
||||||
private RecurringFinanceService $financeSvc;
|
private $financeSvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApplyExpenses constructor.
|
* ApplyExpenses constructor.
|
||||||
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronMonthly $event): void
|
public function handle(CronMonthly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Monthly: Applying monthly expenses');
|
|
||||||
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
|
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ use App\Contracts\Listener;
|
|||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Models\Enums\ExpenseType;
|
use App\Models\Enums\ExpenseType;
|
||||||
use App\Services\Finance\RecurringFinanceService;
|
use App\Services\Finance\RecurringFinanceService;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through and apply any finances that are daily
|
* Go through and apply any finances that are daily
|
||||||
*/
|
*/
|
||||||
class ApplyExpenses extends Listener
|
class ApplyExpenses extends Listener
|
||||||
{
|
{
|
||||||
private RecurringFinanceService $financeSvc;
|
private $financeSvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApplyExpenses constructor.
|
* ApplyExpenses constructor.
|
||||||
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Nightly: Applying daily expenses');
|
|
||||||
$this->financeSvc->processExpenses(ExpenseType::DAILY);
|
$this->financeSvc->processExpenses(ExpenseType::DAILY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Cron\Hourly;
|
namespace App\Cron\Nightly;
|
||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronHourly;
|
use App\Events\CronNightly;
|
||||||
use App\Services\SimBriefService;
|
use App\Services\SimBriefService;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP
|
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP
|
||||||
*/
|
*/
|
||||||
class ClearExpiredSimbrief extends Listener
|
class ClearExpiredSimbrief extends Listener
|
||||||
{
|
{
|
||||||
private SimBriefService $simbriefSvc;
|
private $simbriefSvc;
|
||||||
|
|
||||||
public function __construct(SimBriefService $simbriefSvc)
|
public function __construct(SimBriefService $simbriefSvc)
|
||||||
{
|
{
|
||||||
@@ -20,11 +19,10 @@ class ClearExpiredSimbrief extends Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CronHourly $event
|
* @param \App\Events\CronNightly $event
|
||||||
*/
|
*/
|
||||||
public function handle(CronHourly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Hourly: Removing expired Simbrief entries');
|
|
||||||
$this->simbriefSvc->removeExpiredEntries();
|
$this->simbriefSvc->removeExpiredEntries();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,13 @@ namespace App\Cron\Nightly;
|
|||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Services\VersionService;
|
use App\Services\VersionService;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if any pilots should be set to ON LEAVE status
|
||||||
|
*/
|
||||||
class NewVersionCheck extends Listener
|
class NewVersionCheck extends Listener
|
||||||
{
|
{
|
||||||
private VersionService $versionSvc;
|
private $versionSvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param VersionService $versionSvc
|
* @param VersionService $versionSvc
|
||||||
@@ -26,7 +28,6 @@ class NewVersionCheck extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Nightly: Checking for new version');
|
|
||||||
$this->versionSvc->isNewVersionAvailable();
|
$this->versionSvc->isNewVersionAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ namespace App\Cron\Nightly;
|
|||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
|
use App\Models\Enums\UserState;
|
||||||
|
use App\Models\User;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if any pilots should be set to ON LEAVE status
|
* Determine if any pilots should be set to ON LEAVE status
|
||||||
*/
|
*/
|
||||||
class PilotLeave extends Listener
|
class PilotLeave extends Listener
|
||||||
{
|
{
|
||||||
private UserService $userSvc;
|
private $userSvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PilotLeave constructor.
|
* PilotLeave constructor.
|
||||||
*
|
|
||||||
* @param UserService $userSvc
|
|
||||||
*/
|
*/
|
||||||
public function __construct(UserService $userSvc)
|
public function __construct(UserService $userSvc)
|
||||||
{
|
{
|
||||||
@@ -34,9 +34,13 @@ class PilotLeave extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Cron: Running pilot leave check');
|
if (setting('pilots.auto_leave_days') === 0) {
|
||||||
$users = $this->userSvc->findUsersOnLeave();
|
return;
|
||||||
Log::info('Found '.count($users).' users on leave');
|
}
|
||||||
|
|
||||||
|
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
|
||||||
|
$users = User::where('status', UserState::ACTIVE)
|
||||||
|
->whereDate('updated_at', '<', $date);
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ use App\Contracts\Listener;
|
|||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Models\Journal;
|
use App\Models\Journal;
|
||||||
use App\Repositories\JournalRepository;
|
use App\Repositories\JournalRepository;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This recalculates the balances on all of the journals
|
* This recalculates the balances on all of the journals
|
||||||
*/
|
*/
|
||||||
class RecalculateBalances extends Listener
|
class RecalculateBalances extends Listener
|
||||||
{
|
{
|
||||||
private JournalRepository $journalRepo;
|
private $journalRepo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nightly constructor.
|
* Nightly constructor.
|
||||||
@@ -35,7 +35,7 @@ class RecalculateBalances extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Nightly: Recalculating balances');
|
Log::info('Recalculating balances');
|
||||||
|
|
||||||
$journals = Journal::all();
|
$journals = Journal::all();
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use Illuminate\Support\Facades\Log;
|
|||||||
*/
|
*/
|
||||||
class RecalculateStats extends Listener
|
class RecalculateStats extends Listener
|
||||||
{
|
{
|
||||||
private AircraftService $aircraftSvc;
|
private $aircraftSvc;
|
||||||
private UserService $userSvc;
|
private $userSvc;
|
||||||
|
|
||||||
public function __construct(AircraftService $aircraftSvc, UserService $userSvc)
|
public function __construct(AircraftService $aircraftSvc, UserService $userSvc)
|
||||||
{
|
{
|
||||||
@@ -32,10 +32,10 @@ class RecalculateStats extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Nightly: Recalculating user stats');
|
Log::info('Recalculating user stats');
|
||||||
$this->userSvc->recalculateAllUserStats();
|
$this->userSvc->recalculateAllUserStats();
|
||||||
|
|
||||||
Log::info('Nightly: Recalcuating aircraft status');
|
Log::info('Recalcuating aircraft status');
|
||||||
$this->aircraftSvc->recalculateStats();
|
$this->aircraftSvc->recalculateStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ class SetActiveFlights extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Nightly: Setting active flights');
|
|
||||||
|
|
||||||
$this->checkFlights();
|
$this->checkFlights();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,18 +42,23 @@ class SetActiveFlights extends Listener
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set to visible by default
|
|
||||||
$flight->visible = true;
|
|
||||||
|
|
||||||
// dates aren't set, so just save if there were any changes above
|
// dates aren't set, so just save if there were any changes above
|
||||||
// and move onto the next one
|
// and move onto the next one
|
||||||
if ($flight->start_date === null || $flight->end_date === null) {
|
if ($flight->start_date === null || $flight->end_date === null) {
|
||||||
if ($flight->days !== null && $flight->days > 0) {
|
if ($flight->days !== null && $flight->days > 0) {
|
||||||
$flight->visible = Days::isToday($flight->days);
|
$visible = Days::isToday($flight->days);
|
||||||
if (!$flight->visible) {
|
if ($flight->visible !== $visible) {
|
||||||
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
|
Log::info('Flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden'));
|
||||||
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
|
|
||||||
|
$flight->visible = $visible;
|
||||||
|
if ($visible === false) {
|
||||||
|
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
|
||||||
|
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log::info('Toggling flight '.$flight->ident.' to visible');
|
||||||
|
$flight->visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$flight->save();
|
$flight->save();
|
||||||
@@ -68,11 +71,20 @@ class SetActiveFlights extends Listener
|
|||||||
// and then make sure if days of the week are specified, check that too
|
// and then make sure if days of the week are specified, check that too
|
||||||
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
|
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
|
||||||
if ($flight->days !== null && $flight->days > 0) {
|
if ($flight->days !== null && $flight->days > 0) {
|
||||||
$flight->visible = Days::isToday($flight->days);
|
$visible = Days::isToday($flight->days);
|
||||||
if (!$flight->visible) {
|
if ($flight->visible !== $visible) {
|
||||||
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
|
Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').'');
|
||||||
|
|
||||||
|
$flight->visible = $visible;
|
||||||
|
if ($visible === false) {
|
||||||
|
Log::info('Today='.date('N').', start='.$flight->start_date
|
||||||
|
.', end='.$flight->end_date.', mask='.$flight->days.', in='
|
||||||
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
|
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log::info('Toggling flight '.$flight->ident.' to visible');
|
||||||
|
$flight->visible = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$flight->visible = false;
|
$flight->visible = false;
|
||||||
|
|||||||
@@ -1,43 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\Acars::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'id' => null,
|
||||||
use App\Models\Acars;
|
'pirep_id' => null,
|
||||||
use DateTime;
|
'log' => $faker->text(100),
|
||||||
|
'lat' => $faker->latitude,
|
||||||
class AcarsFactory extends Factory
|
'lon' => $faker->longitude,
|
||||||
{
|
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||||
/**
|
'heading' => $faker->numberBetween(0, 359),
|
||||||
* The name of the factory's corresponding model.
|
'altitude' => $faker->numberBetween(20, 400),
|
||||||
*
|
'vs' => $faker->numberBetween(-5000, 5000),
|
||||||
* @var string
|
'gs' => $faker->numberBetween(300, 500),
|
||||||
*/
|
'transponder' => $faker->numberBetween(200, 9999),
|
||||||
protected $model = Acars::class;
|
'autopilot' => $faker->text(10),
|
||||||
|
'fuel' => $faker->randomFloat(2, 100, 1000),
|
||||||
/**
|
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
|
||||||
* @return array <string, mixed>
|
'sim_time' => $faker->dateTime('now', 'UTC'),
|
||||||
*/
|
];
|
||||||
public function definition(): array
|
});
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'pirep_id' => null,
|
|
||||||
'log' => $this->faker->text(100),
|
|
||||||
'lat' => $this->faker->latitude,
|
|
||||||
'lon' => $this->faker->longitude,
|
|
||||||
'distance' => $this->faker->randomFloat(2, 0, 6000),
|
|
||||||
'heading' => $this->faker->numberBetween(0, 359),
|
|
||||||
'altitude' => $this->faker->numberBetween(20, 400),
|
|
||||||
'vs' => $this->faker->numberBetween(-5000, 5000),
|
|
||||||
'gs' => $this->faker->numberBetween(300, 500),
|
|
||||||
'transponder' => $this->faker->numberBetween(200, 9999),
|
|
||||||
'autopilot' => $this->faker->text(10),
|
|
||||||
'fuel' => $this->faker->randomFloat(2, 100, 1000),
|
|
||||||
'fuel_flow' => $this->faker->randomFloat(2, 100, 1000),
|
|
||||||
'sim_time' => $this->faker->dateTime('now', 'UTC')->format(DateTime::ATOM),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,51 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'id' => null,
|
||||||
use App\Models\Aircraft;
|
'subfleet_id' => function () {
|
||||||
use App\Models\Airport;
|
return factory(App\Models\Subfleet::class)->create()->id;
|
||||||
use App\Models\Enums\AircraftState;
|
},
|
||||||
use App\Models\Enums\AircraftStatus;
|
'airport_id' => function () {
|
||||||
use App\Models\Subfleet;
|
return factory(App\Models\Airport::class)->create()->id;
|
||||||
use App\Support\ICAO;
|
},
|
||||||
use DateTime;
|
'iata' => $faker->unique()->text(5),
|
||||||
|
'icao' => $faker->unique()->text(5),
|
||||||
class AircraftFactory extends Factory
|
'name' => $faker->text(50),
|
||||||
{
|
'registration' => $faker->unique()->text(10),
|
||||||
/**
|
'hex_code' => \App\Support\ICAO::createHexCode(),
|
||||||
* The name of the factory's corresponding model.
|
'zfw' => $faker->randomFloat(2, 0, 50000),
|
||||||
*
|
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
||||||
* @var string
|
'state' => \App\Models\Enums\AircraftState::PARKED,
|
||||||
*/
|
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||||
protected $model = Aircraft::class;
|
'updated_at' => function (array $pirep) {
|
||||||
|
return $pirep['created_at'];
|
||||||
/**
|
},
|
||||||
* Define the model's default state.
|
];
|
||||||
*
|
});
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'subfleet_id' => fn () => Subfleet::factory()->create()->id,
|
|
||||||
'airport_id' => fn () => Airport::factory()->create()->id,
|
|
||||||
'iata' => $this->faker->unique()->text(5),
|
|
||||||
'icao' => $this->faker->unique()->text(5),
|
|
||||||
'name' => $this->faker->text(50),
|
|
||||||
'registration' => $this->faker->unique()->text(10),
|
|
||||||
'hex_code' => ICAO::createHexCode(),
|
|
||||||
'mtow' => $this->faker->randomFloat(2, 0, 50000),
|
|
||||||
'zfw' => $this->faker->randomFloat(2, 0, 50000),
|
|
||||||
'status' => AircraftStatus::ACTIVE,
|
|
||||||
'state' => AircraftState::PARKED,
|
|
||||||
'created_at' => $this->faker->dateTimeBetween('-1 week')->format(DateTime::ATOM),
|
|
||||||
'updated_at' => fn (array $pirep) => $pirep['created_at'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,41 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Airline;
|
|
||||||
use Hashids\Hashids;
|
use Hashids\Hashids;
|
||||||
|
|
||||||
class AirlineFactory extends Factory
|
/*
|
||||||
{
|
* Add any number of airports. Don't really care if they're real or not
|
||||||
/**
|
*/
|
||||||
* The name of the factory's corresponding model.
|
$factory->define(App\Models\Airline::class, function (Faker $faker) {
|
||||||
*
|
return [
|
||||||
* @var string
|
'id' => null,
|
||||||
*/
|
'icao' => function (array $apt) use ($faker) {
|
||||||
protected $model = Airline::class;
|
$hashids = new Hashids(microtime(), 5);
|
||||||
|
$mt = str_replace('.', '', microtime(true));
|
||||||
|
|
||||||
/**
|
return $hashids->encode($mt);
|
||||||
* Define the model's default state.
|
},
|
||||||
*
|
'iata' => function (array $apt) {
|
||||||
* @return array<string, mixed>
|
return $apt['icao'];
|
||||||
*/
|
},
|
||||||
public function definition(): array
|
'name' => $faker->sentence(3),
|
||||||
{
|
'country' => $faker->country,
|
||||||
return [
|
'active' => 1,
|
||||||
'id' => null,
|
];
|
||||||
'icao' => function (array $apt): string {
|
});
|
||||||
$hashids = new Hashids(microtime(), 5);
|
|
||||||
$mt = str_replace('.', '', microtime(true));
|
|
||||||
|
|
||||||
return $hashids->encode($mt);
|
|
||||||
},
|
|
||||||
'iata' => fn (array $apt) => $apt['icao'],
|
|
||||||
'name' => $this->faker->sentence(3),
|
|
||||||
'country' => $this->faker->country,
|
|
||||||
'active' => 1,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,36 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
/*
|
||||||
|
* Create an ICAO for use in the factory.
|
||||||
use App\Contracts\Factory;
|
*/
|
||||||
use App\Models\Airport;
|
if (!function_exists('createFactoryICAO')) {
|
||||||
|
function createFactoryICAO(): string
|
||||||
class AirportFactory extends Factory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = Airport::class;
|
|
||||||
|
|
||||||
protected array $usedIcaos = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a fake ICAO
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function createFactoryICAO(): string
|
|
||||||
{
|
{
|
||||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||||
$max = strlen($characters) - 1;
|
$max = strlen($characters) - 1;
|
||||||
$string = '';
|
$string = '';
|
||||||
for ($i = 0; $i < 5; $i++) {
|
for ($i = 0; $i < 4; $i++) {
|
||||||
try {
|
try {
|
||||||
$string .= $characters[random_int(0, $max)];
|
$string .= $characters[random_int(0, $max)];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -39,35 +20,37 @@ class AirportFactory extends Factory
|
|||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => function () {
|
|
||||||
do {
|
|
||||||
$airport = $this->createFactoryICAO();
|
|
||||||
} while (in_array($airport, $this->usedIcaos, true));
|
|
||||||
|
|
||||||
return $airport;
|
|
||||||
},
|
|
||||||
'icao' => fn (array $apt) => $apt['id'],
|
|
||||||
'iata' => fn (array $apt) => $apt['id'],
|
|
||||||
'name' => $this->faker->sentence(3),
|
|
||||||
'country' => $this->faker->country,
|
|
||||||
'timezone' => $this->faker->timezone,
|
|
||||||
'lat' => $this->faker->latitude,
|
|
||||||
'lon' => $this->faker->longitude,
|
|
||||||
'hub' => false,
|
|
||||||
'notes' => null,
|
|
||||||
'ground_handling_cost' => $this->faker->randomFloat(2, 0, 500),
|
|
||||||
'fuel_100ll_cost' => $this->faker->randomFloat(2, 1, 10),
|
|
||||||
'fuel_jeta_cost' => $this->faker->randomFloat(2, 1, 10),
|
|
||||||
'fuel_mogas_cost' => $this->faker->randomFloat(2, 1, 10),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add any number of airports. Don't really care if they're real or not
|
||||||
|
*/
|
||||||
|
$factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||||
|
$usedIcaos = [];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => function () use ($usedIcaos) {
|
||||||
|
do {
|
||||||
|
$airport = createFactoryICAO();
|
||||||
|
} while (in_array($airport, $usedIcaos, true));
|
||||||
|
|
||||||
|
return $airport;
|
||||||
|
},
|
||||||
|
'icao' => function (array $apt) {
|
||||||
|
return $apt['id'];
|
||||||
|
},
|
||||||
|
'iata' => function (array $apt) {
|
||||||
|
return $apt['id'];
|
||||||
|
},
|
||||||
|
'name' => $faker->sentence(3),
|
||||||
|
'country' => $faker->country,
|
||||||
|
'timezone' => $faker->timezone,
|
||||||
|
'lat' => $faker->latitude,
|
||||||
|
'lon' => $faker->longitude,
|
||||||
|
'hub' => false,
|
||||||
|
'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
|
||||||
|
'fuel_100ll_cost' => $faker->randomFloat(2, 1, 10),
|
||||||
|
'fuel_jeta_cost' => $faker->randomFloat(2, 1, 10),
|
||||||
|
'fuel_mogas_cost' => $faker->randomFloat(2, 1, 10),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Award;
|
|
||||||
|
|
||||||
class AwardFactory extends Factory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = Award::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'name' => $this->faker->name,
|
|
||||||
'description' => $this->faker->text(10),
|
|
||||||
'ref_model' => null,
|
|
||||||
'ref_model_params' => null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
app/Database/factories/AwardsFactory.php
Normal file
13
app/Database/factories/AwardsFactory.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(App\Models\Award::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'id' => null,
|
||||||
|
'name' => $faker->name,
|
||||||
|
'description' => $faker->text(10),
|
||||||
|
'ref_model' => null,
|
||||||
|
'ref_model_params' => null,
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -1,39 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Enums\ExpenseType;
|
use App\Models\Enums\ExpenseType;
|
||||||
use App\Models\Expense;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
class ExpenseFactory extends Factory
|
$factory->define(App\Models\Expense::class, function (Faker $faker) {
|
||||||
{
|
return [
|
||||||
/**
|
'id' => null,
|
||||||
* The name of the factory's corresponding model.
|
'airline_id' => null,
|
||||||
*
|
'name' => $faker->text(20),
|
||||||
* @var string
|
'amount' => $faker->randomFloat(2, 100, 1000),
|
||||||
*/
|
'type' => ExpenseType::FLIGHT,
|
||||||
protected $model = Expense::class;
|
'multiplier' => false,
|
||||||
|
'ref_model' => \App\Models\Expense::class,
|
||||||
/**
|
'ref_model_id' => null,
|
||||||
* Define the model's default state.
|
'active' => true,
|
||||||
*
|
];
|
||||||
* @return array<string, mixed>
|
});
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'airline_id' => null,
|
|
||||||
'name' => $this->faker->text(20),
|
|
||||||
'amount' => $this->faker->randomFloat(2, 100, 1000),
|
|
||||||
'type' => ExpenseType::FLIGHT,
|
|
||||||
'multiplier' => false,
|
|
||||||
'ref_model' => \App\Models\Expense::class,
|
|
||||||
'ref_model_id' => null,
|
|
||||||
'active' => true,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,35 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\Fare::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'id' => null,
|
||||||
use App\Models\Fare;
|
'code' => $faker->unique()->text(50),
|
||||||
|
'name' => $faker->text(50),
|
||||||
class FareFactory extends Factory
|
'price' => $faker->randomFloat(2, 100, 1000),
|
||||||
{
|
'cost' => function (array $fare) {
|
||||||
/**
|
return round($fare['price'] / 2);
|
||||||
* The name of the factory's corresponding model.
|
},
|
||||||
*
|
'capacity' => $faker->randomFloat(0, 20, 500),
|
||||||
* @var string
|
];
|
||||||
*/
|
});
|
||||||
protected $model = Fare::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'code' => $this->faker->unique()->text(50),
|
|
||||||
'name' => $this->faker->text(50),
|
|
||||||
'price' => $this->faker->randomFloat(2, 100, 1000),
|
|
||||||
'cost' => fn (array $fare) => round($fare['price'] / 2),
|
|
||||||
'capacity' => $this->faker->randomFloat(0, 20, 500),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,58 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Create flights
|
||||||
|
*/
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
$factory->define(App\Models\Flight::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
namespace App\Database\Factories;
|
'id' => $faker->unique()->numberBetween(10, 10000000),
|
||||||
|
'airline_id' => function () {
|
||||||
use App\Contracts\Factory;
|
return factory(App\Models\Airline::class)->create()->id;
|
||||||
use App\Models\Flight;
|
},
|
||||||
use DateTime;
|
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
|
||||||
|
'route_code' => $faker->randomElement(['', $faker->text(5)]),
|
||||||
class FlightFactory extends Factory
|
'route_leg' => $faker->randomElement(['', $faker->numberBetween(0, 1000)]),
|
||||||
{
|
'dpt_airport_id' => function () {
|
||||||
/**
|
return factory(App\Models\Airport::class)->create()->id;
|
||||||
* The name of the factory's corresponding model.
|
},
|
||||||
*
|
'arr_airport_id' => function () {
|
||||||
* @var string
|
return factory(App\Models\Airport::class)->create()->id;
|
||||||
*/
|
},
|
||||||
protected $model = Flight::class;
|
'alt_airport_id' => function () {
|
||||||
|
return factory(App\Models\Airport::class)->create()->id;
|
||||||
/**
|
},
|
||||||
* Define the model's default state.
|
'distance' => $faker->numberBetween(1, 1000),
|
||||||
*
|
'route' => null,
|
||||||
* @return array<string, mixed>
|
'level' => 0,
|
||||||
*/
|
'dpt_time' => $faker->time(),
|
||||||
public function definition(): array
|
'arr_time' => $faker->time(),
|
||||||
{
|
'flight_time' => $faker->numberBetween(60, 360),
|
||||||
return [
|
'load_factor' => $faker->randomElement([15, 20, 50, 90, 100]),
|
||||||
'id' => $this->faker->unique()->numberBetween(10, 10000000),
|
'load_factor_variance' => $faker->randomElement([15, 20, 50, 90, 100]),
|
||||||
'airline_id' => fn () => \App\Models\Airline::factory()->create()->id,
|
'has_bid' => false,
|
||||||
'flight_number' => $this->faker->unique()->numberBetween(10, 1000000),
|
'active' => true,
|
||||||
'route_code' => $this->faker->randomElement(['', $this->faker->text(5)]),
|
'visible' => true,
|
||||||
'route_leg' => $this->faker->randomElement(
|
'days' => 0,
|
||||||
['', $this->faker->numberBetween(0, 1000)]
|
'start_date' => null,
|
||||||
),
|
'end_date' => null,
|
||||||
'dpt_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
|
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||||
'arr_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
|
'updated_at' => static function (array $flight) {
|
||||||
'alt_airport_id' => static fn () => \App\Models\Airport::factory()->create()->id,
|
return $flight['created_at'];
|
||||||
'distance' => $this->faker->numberBetween(1, 1000),
|
},
|
||||||
'route' => null,
|
];
|
||||||
'level' => 0,
|
});
|
||||||
'dpt_time' => $this->faker->time(),
|
|
||||||
'arr_time' => $this->faker->time(),
|
|
||||||
'flight_time' => $this->faker->numberBetween(60, 360),
|
|
||||||
'load_factor' => $this->faker->randomElement([15, 20, 50, 90, 100]),
|
|
||||||
'load_factor_variance' => $this->faker->randomElement([15, 20, 50, 90, 100]),
|
|
||||||
'has_bid' => false,
|
|
||||||
'active' => true,
|
|
||||||
'visible' => true,
|
|
||||||
'days' => 0,
|
|
||||||
'start_date' => null,
|
|
||||||
'end_date' => null,
|
|
||||||
'created_at' => $this->faker->dateTimeBetween('-1 week')->format(
|
|
||||||
DateTime::ATOM
|
|
||||||
),
|
|
||||||
'updated_at' => static fn (array $flight) => $flight['created_at'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,30 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\Journal::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'currency' => 'USD',
|
||||||
use App\Models\Journal;
|
];
|
||||||
|
});
|
||||||
class JournalFactory extends Factory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = Journal::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'currency' => 'USD',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,39 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\JournalTransactions::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
|
||||||
use App\Models\Journal;
|
'journal_id' => function () {
|
||||||
use App\Models\JournalTransaction;
|
return factory(App\Models\Journal::class)->create()->id;
|
||||||
use Carbon\Carbon;
|
},
|
||||||
use Ramsey\Uuid\Uuid;
|
'credit' => $faker->numberBetween(100, 10000),
|
||||||
|
'debit' => $faker->numberBetween(100, 10000),
|
||||||
class JournalTransactionsFactory extends Factory
|
'currency' => 'USD',
|
||||||
{
|
'memo' => $faker->sentence(6),
|
||||||
/**
|
'post_date' => \Carbon\Carbon::now(),
|
||||||
* The name of the factory's corresponding model.
|
];
|
||||||
*
|
});
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = JournalTransaction::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'transaction_group' => Uuid::uuid4()->toString(),
|
|
||||||
'journal_id' => fn () => Journal::factory()->create()->id,
|
|
||||||
'credit' => $this->faker->numberBetween(100, 10000),
|
|
||||||
'debit' => $this->faker->numberBetween(100, 10000),
|
|
||||||
'currency' => 'USD',
|
|
||||||
'memo' => $this->faker->sentence(6),
|
|
||||||
'post_date' => Carbon::now('UTC')->toDateTimeString(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,36 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Enums\NavaidType;
|
use App\Models\Enums\NavaidType;
|
||||||
use App\Models\Navdata;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
class NavdataFactory extends Factory
|
$factory->define(App\Models\Navdata::class, function (Faker $faker) {
|
||||||
{
|
return [
|
||||||
/**
|
'id' => str_replace(' ', '', str_replace('.', '', $faker->unique()->text(5))),
|
||||||
* The name of the factory's corresponding model.
|
'name' => str_replace('.', '', $faker->unique()->word),
|
||||||
*
|
'type' => $faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
|
||||||
* @var string
|
'lat' => $faker->latitude,
|
||||||
*/
|
'lon' => $faker->longitude,
|
||||||
protected $model = Navdata::class;
|
'freq' => $faker->randomFloat(2, 100, 1000),
|
||||||
|
];
|
||||||
/**
|
});
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => str_replace(' ', '', str_replace('.', '', $this->faker->unique()->text(5))),
|
|
||||||
'name' => str_replace('.', '', $this->faker->unique()->word),
|
|
||||||
'type' => $this->faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
|
|
||||||
'lat' => $this->faker->latitude,
|
|
||||||
'lon' => $this->faker->longitude,
|
|
||||||
'freq' => $this->faker->randomFloat(2, 100, 1000),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\News::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'id' => null,
|
||||||
use App\Models\News;
|
'user_id' => function () {
|
||||||
|
return factory(App\Models\User::class)->create()->id;
|
||||||
class NewsFactory extends Factory
|
},
|
||||||
{
|
'subject' => $faker->text(),
|
||||||
/**
|
'body' => $faker->sentence,
|
||||||
* The name of the factory's corresponding model.
|
];
|
||||||
*
|
});
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = News::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'user_id' => fn () => \App\Models\User::factory()->create()->id,
|
|
||||||
'subject' => $this->faker->text(),
|
|
||||||
'body' => $this->faker->sentence,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,74 +1,69 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Airline;
|
|
||||||
use App\Models\Enums\PirepSource;
|
use App\Models\Enums\PirepSource;
|
||||||
use App\Models\Enums\PirepState;
|
use App\Models\Enums\PirepState;
|
||||||
use App\Models\Enums\PirepStatus;
|
use App\Models\Enums\PirepStatus;
|
||||||
use App\Models\Flight;
|
|
||||||
use App\Models\Pirep;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
class PirepFactory extends Factory
|
/*
|
||||||
{
|
* Create a new PIREP
|
||||||
/**
|
*/
|
||||||
* The name of the factory's corresponding model.
|
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||||
*
|
$airline = factory(App\Models\Airline::class)->create();
|
||||||
* @var string
|
$flight = factory(App\Models\Flight::class)->create([
|
||||||
*/
|
'airline_id' => $airline->id,
|
||||||
protected $model = Pirep::class;
|
]);
|
||||||
|
|
||||||
/**
|
return [
|
||||||
* Define the model's default state.
|
'id' => $faker->unique()->numberBetween(10, 10000000),
|
||||||
*
|
'airline_id' => function () use ($airline) {
|
||||||
* @return array<string, mixed>
|
return $airline->id;
|
||||||
*/
|
},
|
||||||
public function definition(): array
|
'user_id' => function () {
|
||||||
{
|
return factory(App\Models\User::class)->create()->id;
|
||||||
/** @var Airline $airline */
|
},
|
||||||
$airline = Airline::factory()->create();
|
'aircraft_id' => function () {
|
||||||
|
return factory(App\Models\Aircraft::class)->create()->id;
|
||||||
/** @var Flight $flight */
|
},
|
||||||
$flight = Flight::factory()->create(['airline_id' => $airline->id]);
|
'flight_id' => function () use ($flight) {
|
||||||
|
return $flight->id;
|
||||||
return [
|
},
|
||||||
'id' => $this->faker->unique()->numberBetween(10, 10000000),
|
'flight_number' => function () use ($flight) {
|
||||||
'airline_id' => fn () => $airline->id,
|
return $flight->flight_number;
|
||||||
'user_id' => fn () => \App\Models\User::factory()->create()->id,
|
},
|
||||||
'aircraft_id' => fn () => \App\Models\Aircraft::factory()->create()->id,
|
'route_code' => null,
|
||||||
'flight_id' => fn () => $flight->id,
|
'route_leg' => null,
|
||||||
'flight_number' => fn () => $flight->flight_number,
|
'dpt_airport_id' => function () use ($flight) {
|
||||||
'route_code' => null,
|
return $flight->dpt_airport_id;
|
||||||
'route_leg' => null,
|
},
|
||||||
'dpt_airport_id' => fn () => $flight->dpt_airport_id,
|
'arr_airport_id' => function () use ($flight) {
|
||||||
'arr_airport_id' => fn () => $flight->arr_airport_id,
|
return $flight->arr_airport_id;
|
||||||
'level' => $this->faker->numberBetween(20, 400),
|
},
|
||||||
'distance' => $this->faker->randomFloat(2, 0, 6000),
|
'level' => $faker->numberBetween(20, 400),
|
||||||
'planned_distance' => $this->faker->randomFloat(2, 0, 6000),
|
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||||
'flight_time' => $this->faker->numberBetween(60, 360),
|
'planned_distance' => $faker->randomFloat(2, 0, 6000),
|
||||||
'planned_flight_time' => $this->faker->numberBetween(60, 360),
|
'flight_time' => $faker->numberBetween(60, 360),
|
||||||
'zfw' => $this->faker->randomFloat(2),
|
'planned_flight_time' => $faker->numberBetween(60, 360),
|
||||||
'block_fuel' => $this->faker->randomFloat(2, 0, 1000),
|
'zfw' => $faker->randomFloat(2),
|
||||||
'fuel_used' => fn (array $pirep) => round($pirep['block_fuel'] * .9, 2),
|
'block_fuel' => $faker->randomFloat(2, 0, 1000),
|
||||||
'block_on_time' => Carbon::now('UTC'),
|
'fuel_used' => function (array $pirep) {
|
||||||
'block_off_time' => fn (array $pirep) => $pirep['block_on_time']->subMinutes(
|
return round($pirep['block_fuel'] * .9, 2); // 90% of the fuel loaded was used
|
||||||
$pirep['flight_time']
|
},
|
||||||
),
|
'block_on_time' => Carbon::now('UTC'),
|
||||||
'route' => $this->faker->text(200),
|
'block_off_time' => function (array $pirep) {
|
||||||
'notes' => $this->faker->text(200),
|
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
|
||||||
'source' => $this->faker->randomElement(
|
},
|
||||||
[PirepSource::MANUAL, PirepSource::ACARS]
|
'route' => $faker->text(200),
|
||||||
),
|
'notes' => $faker->text(200),
|
||||||
'source_name' => 'TestFactory',
|
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
||||||
'state' => PirepState::PENDING,
|
'source_name' => 'TestFactory',
|
||||||
'status' => PirepStatus::SCHEDULED,
|
'state' => PirepState::PENDING,
|
||||||
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
|
'status' => PirepStatus::SCHEDULED,
|
||||||
'created_at' => Carbon::now('UTC')->toDateTimeString(),
|
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
|
||||||
'updated_at' => fn (array $pirep) => $pirep['created_at'],
|
'created_at' => Carbon::now('UTC')->toDateTimeString(),
|
||||||
];
|
'updated_at' => function (array $pirep) {
|
||||||
}
|
return $pirep['created_at'];
|
||||||
}
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,37 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
/*
|
||||||
|
* id: 2
|
||||||
use App\Contracts\Factory;
|
name: Junior First Officer
|
||||||
use App\Models\Rank;
|
hours: 10
|
||||||
|
auto_approve_acars: 1
|
||||||
class RankFactory extends Factory
|
auto_approve_manual: 1
|
||||||
{
|
*/
|
||||||
/**
|
$factory->define(App\Models\Rank::class, function (Faker $faker) {
|
||||||
* The name of the factory's corresponding model.
|
return [
|
||||||
*
|
'id' => null,
|
||||||
* @var string
|
'name' => $faker->unique()->text(50),
|
||||||
*/
|
'hours' => $faker->numberBetween(10, 50),
|
||||||
protected $model = Rank::class;
|
'acars_base_pay_rate' => $faker->numberBetween(10, 100),
|
||||||
|
'manual_base_pay_rate' => $faker->numberBetween(10, 100),
|
||||||
/**
|
'auto_approve_acars' => 0,
|
||||||
* Define the model's default state.
|
'auto_approve_manual' => 0,
|
||||||
*
|
'auto_promote' => 0,
|
||||||
* @return array<string, mixed>
|
];
|
||||||
*/
|
});
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'name' => $this->faker->unique()->text(50),
|
|
||||||
'hours' => $this->faker->numberBetween(10, 50),
|
|
||||||
'acars_base_pay_rate' => $this->faker->numberBetween(10, 100),
|
|
||||||
'manual_base_pay_rate' => $this->faker->numberBetween(10, 100),
|
|
||||||
'auto_approve_acars' => 0,
|
|
||||||
'auto_approve_manual' => 0,
|
|
||||||
'auto_promote' => 0,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Role;
|
|
||||||
|
|
||||||
class RoleFactory extends Factory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = Role::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'name' => $this->faker->name,
|
|
||||||
'display_name' => $this->faker->name,
|
|
||||||
'read_only' => false,
|
|
||||||
'disable_activity_checks' => $this->faker->boolean(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\SimBrief;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class SimBriefFactory extends Factory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = SimBrief::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => $this->faker->unique()->numberBetween(10, 10000000),
|
|
||||||
'user_id' => null,
|
|
||||||
'flight_id' => null,
|
|
||||||
'pirep_id' => null,
|
|
||||||
'acars_xml' => '',
|
|
||||||
'ofp_xml' => '',
|
|
||||||
'created_at' => Carbon::now('UTC')->toDateTimeString(),
|
|
||||||
'updated_at' => fn (array $sb) => $sb['created_at'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
app/Database/factories/SimbriefFactory.php
Normal file
21
app/Database/factories/SimbriefFactory.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(App\Models\SimBrief::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'id' => $faker->unique()->numberBetween(10, 10000000),
|
||||||
|
'user_id' => null,
|
||||||
|
'flight_id' => null,
|
||||||
|
'pirep_id' => null,
|
||||||
|
'acars_xml' => '',
|
||||||
|
'ofp_xml' => '',
|
||||||
|
'created_at' => Carbon::now('UTC')->toDateTimeString(),
|
||||||
|
'updated_at' => function (array $sb) {
|
||||||
|
return $sb['created_at'];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -1,34 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
use App\Contracts\Factory;
|
'id' => null,
|
||||||
use App\Models\Subfleet;
|
'airline_id' => function () {
|
||||||
|
return factory(App\Models\Airline::class)->create()->id;
|
||||||
class SubfleetFactory extends Factory
|
},
|
||||||
{
|
'name' => $faker->unique()->text(50),
|
||||||
/**
|
'type' => $faker->unique()->text(7),
|
||||||
* The name of the factory's corresponding model.
|
'ground_handling_multiplier' => $faker->numberBetween(50, 200),
|
||||||
*
|
];
|
||||||
* @var string
|
});
|
||||||
*/
|
|
||||||
protected $model = Subfleet::class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function definition(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => null,
|
|
||||||
'airline_id' => fn () => \App\Models\Airline::factory()->create()->id,
|
|
||||||
'name' => $this->faker->unique()->text(50),
|
|
||||||
'type' => $this->faker->unique()->text(7),
|
|
||||||
'ground_handling_multiplier' => $this->faker->numberBetween(50, 200),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,54 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
||||||
|
|
||||||
namespace App\Database\Factories;
|
|
||||||
|
|
||||||
use App\Contracts\Factory;
|
|
||||||
use App\Models\Airline;
|
|
||||||
use App\Models\Enums\UserState;
|
use App\Models\Enums\UserState;
|
||||||
use App\Models\User;
|
use Faker\Generator as Faker;
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
|
|
||||||
class UserFactory extends Factory
|
$factory->define(App\Models\User::class, function (Faker $faker) {
|
||||||
{
|
static $password;
|
||||||
/**
|
|
||||||
* The name of the factory's corresponding model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $model = User::class;
|
|
||||||
|
|
||||||
/**
|
return [
|
||||||
* @var string
|
'id' => null,
|
||||||
*/
|
'pilot_id' => null,
|
||||||
private static string $password;
|
'name' => $faker->name,
|
||||||
|
'email' => $faker->safeEmail,
|
||||||
/**
|
'password' => $password ?: $password = Hash::make('secret'),
|
||||||
* Define the model's default state.
|
'api_key' => $faker->sha1,
|
||||||
*
|
'airline_id' => function () {
|
||||||
* @return array<string, mixed>
|
return factory(App\Models\Airline::class)->create()->id;
|
||||||
*/
|
},
|
||||||
public function definition(): array
|
'rank_id' => 1,
|
||||||
{
|
'flights' => $faker->numberBetween(0, 1000),
|
||||||
if (empty(self::$password)) {
|
'flight_time' => $faker->numberBetween(0, 10000),
|
||||||
self::$password = Hash::make('secret');
|
'transfer_time' => $faker->numberBetween(0, 10000),
|
||||||
}
|
'state' => UserState::ACTIVE,
|
||||||
|
'remember_token' => $faker->unique()->text(5),
|
||||||
return [
|
];
|
||||||
'id' => null,
|
});
|
||||||
'pilot_id' => null,
|
|
||||||
'name' => $this->faker->name,
|
|
||||||
'email' => $this->faker->safeEmail,
|
|
||||||
'password' => self::$password,
|
|
||||||
'api_key' => $this->faker->sha1,
|
|
||||||
'airline_id' => fn () => Airline::factory()->create()->id,
|
|
||||||
'rank_id' => 1,
|
|
||||||
'flights' => $this->faker->numberBetween(0, 1000),
|
|
||||||
'flight_time' => $this->faker->numberBetween(0, 10000),
|
|
||||||
'transfer_time' => $this->faker->numberBetween(0, 10000),
|
|
||||||
'state' => UserState::ACTIVE,
|
|
||||||
'remember_token' => $this->faker->unique()->text(5),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ use App\Contracts\Migration;
|
|||||||
use App\Services\Installer\SeederService;
|
use App\Services\Installer\SeederService;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateSettingsTable extends Migration
|
||||||
|
{
|
||||||
private $seederSvc;
|
private $seederSvc;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -49,4 +50,4 @@ return new class() extends Migration {
|
|||||||
{
|
{
|
||||||
Schema::dropIfExists('settings');
|
Schema::dropIfExists('settings');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ use App\Models\Pirep;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateUsersTable extends Migration
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -54,4 +55,4 @@ return new class() extends Migration {
|
|||||||
{
|
{
|
||||||
Schema::dropIfExists('users');
|
Schema::dropIfExists('users');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -2,9 +2,14 @@
|
|||||||
|
|
||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class() extends Migration {
|
class RolesPermissionsTables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
// Create table for storing roles
|
// Create table for storing roles
|
||||||
@@ -74,6 +79,11 @@ return new class() extends Migration {
|
|||||||
$this->addData('roles', $roles);
|
$this->addData('roles', $roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('permission_user');
|
Schema::dropIfExists('permission_user');
|
||||||
@@ -82,4 +92,4 @@ return new class() extends Migration {
|
|||||||
Schema::dropIfExists('role_user');
|
Schema::dropIfExists('role_user');
|
||||||
Schema::dropIfExists('roles');
|
Schema::dropIfExists('roles');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ use App\Contracts\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreatePasswordResetsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('password_resets', function (Blueprint $table) {
|
Schema::create('password_resets', function (Blueprint $table) {
|
||||||
@@ -14,8 +20,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('password_resets');
|
Schema::dropIfExists('password_resets');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ use App\Contracts\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateSessionsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('sessions', function (Blueprint $table) {
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
@@ -17,8 +23,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('sessions');
|
Schema::dropIfExists('sessions');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateAirlinesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('airlines', function (Blueprint $table) {
|
Schema::create('airlines', function (Blueprint $table) {
|
||||||
@@ -26,8 +32,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('airlines');
|
Schema::dropIfExists('airlines');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ use App\Models\Enums\AircraftState;
|
|||||||
use App\Models\Enums\AircraftStatus;
|
use App\Models\Enums\AircraftStatus;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateAircraftsTable extends Migration
|
||||||
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('aircraft', function (Blueprint $table) {
|
Schema::create('aircraft', function (Blueprint $table) {
|
||||||
@@ -33,4 +34,4 @@ return new class() extends Migration {
|
|||||||
{
|
{
|
||||||
Schema::dropIfExists('aircraft');
|
Schema::dropIfExists('aircraft');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateFaresTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('fares', function (Blueprint $table) {
|
Schema::create('fares', function (Blueprint $table) {
|
||||||
@@ -19,8 +25,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('fares');
|
Schema::dropIfExists('fares');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateAirportsTable extends Migration
|
||||||
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('airports', function (Blueprint $table) {
|
Schema::create('airports', function (Blueprint $table) {
|
||||||
@@ -32,4 +33,4 @@ return new class() extends Migration {
|
|||||||
{
|
{
|
||||||
Schema::dropIfExists('airports');
|
Schema::dropIfExists('airports');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ use App\Contracts\Model;
|
|||||||
use App\Models\Enums\FlightType;
|
use App\Models\Enums\FlightType;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateFlightTables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('flights', function (Blueprint $table) {
|
Schema::create('flights', function (Blueprint $table) {
|
||||||
@@ -97,4 +103,4 @@ return new class() extends Migration {
|
|||||||
Schema::drop('flight_subfleet');
|
Schema::drop('flight_subfleet');
|
||||||
Schema::drop('flights');
|
Schema::drop('flights');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateRanksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('ranks', function (Blueprint $table) {
|
Schema::create('ranks', function (Blueprint $table) {
|
||||||
@@ -24,8 +30,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('ranks');
|
Schema::dropIfExists('ranks');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
use App\Contracts\Migration;
|
use App\Contracts\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
/**
|
||||||
|
* Class CreateSubfleetTables
|
||||||
|
*/
|
||||||
|
class CreateSubfleetTables extends Migration
|
||||||
|
{
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('subfleets', function (Blueprint $table) {
|
Schema::create('subfleets', function (Blueprint $table) {
|
||||||
@@ -44,10 +48,15 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('subfleets');
|
Schema::dropIfExists('subfleets');
|
||||||
Schema::dropIfExists('subfleet_fare');
|
Schema::dropIfExists('subfleet_fare');
|
||||||
Schema::dropIfExists('subfleet_rank');
|
Schema::dropIfExists('subfleet_rank');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use App\Models\Enums\PirepState;
|
|||||||
use App\Models\Enums\PirepStatus;
|
use App\Models\Enums\PirepStatus;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreatePirepTables extends Migration
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
@@ -105,4 +106,4 @@ return new class() extends Migration {
|
|||||||
Schema::dropIfExists('pirep_fields');
|
Schema::dropIfExists('pirep_fields');
|
||||||
Schema::dropIfExists('pirep_field_values');
|
Schema::dropIfExists('pirep_field_values');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ use App\Contracts\Model;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
class CreateBidsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('bids', function (Blueprint $table) {
|
Schema::create('bids', function (Blueprint $table) {
|
||||||
@@ -19,8 +25,13 @@ return new class() extends Migration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('bids');
|
Schema::dropIfExists('bids');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user