Compare commits
236 Commits
v7.0.0-bet
...
7.0.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
073e48c396 | ||
|
|
a335ed8e9b | ||
|
|
02973a0f22 | ||
|
|
bffa5ebde2 | ||
|
|
3ec64c989b | ||
|
|
c643833496 | ||
|
|
759979fc10 | ||
|
|
8859682366 | ||
|
|
f5183babf6 | ||
|
|
db087d0ccb | ||
|
|
70d43e6e53 | ||
|
|
a45770732a | ||
|
|
ec4f10d43a | ||
|
|
eff9f6fec6 | ||
|
|
96394228ea | ||
|
|
ae68550448 | ||
|
|
a2ea9b29ba | ||
|
|
1725ea5a9e | ||
|
|
12679e85a8 | ||
|
|
79d4928e18 | ||
|
|
7a34756188 | ||
|
|
97baf98d04 | ||
|
|
eb27c94637 | ||
|
|
5f9e7d5754 | ||
|
|
6e9dcf8a31 | ||
|
|
aedb1f22b6 | ||
|
|
41baefbf4a | ||
|
|
3c21047c15 | ||
|
|
52332c250b | ||
|
|
0c89d36a16 | ||
|
|
4ac781a20d | ||
|
|
d68d8791bd | ||
|
|
23eb9dcbda | ||
|
|
7a76ac4226 | ||
|
|
37fc761567 | ||
|
|
1b82ef6c88 | ||
|
|
7ace8bccd6 | ||
|
|
b213f2bb4c | ||
|
|
0d1f38cf85 | ||
|
|
e62e4a865d | ||
|
|
09f3e3cfdf | ||
|
|
fd2f4f2150 | ||
|
|
651174bda8 | ||
|
|
bbec276da8 | ||
|
|
25999d55a3 | ||
|
|
6018a6dcaa | ||
|
|
94ba5d8680 | ||
|
|
3d6a29795b | ||
|
|
dd2b297cc5 | ||
|
|
7fdaf62ef5 | ||
|
|
182aabf426 | ||
|
|
91a5eb535d | ||
|
|
b6189bab7e | ||
|
|
dc51897314 | ||
|
|
c1103afe8f | ||
|
|
39fbdcb787 | ||
|
|
47be7507f0 | ||
|
|
5cafebe4d6 | ||
|
|
becf6c95f0 | ||
|
|
380c9d13b6 | ||
|
|
a08c9db284 | ||
|
|
ff6ba4c29a | ||
|
|
f6465bea58 | ||
|
|
5cce1b3040 | ||
|
|
e12188b7d3 | ||
|
|
092b9fc9dc | ||
|
|
6292b05ad5 | ||
|
|
732a0c4088 | ||
|
|
753804b71b | ||
|
|
9f3ba05880 | ||
|
|
3a97071fcf | ||
|
|
d4c172e734 | ||
|
|
95147e31bf | ||
|
|
63485d5a0f | ||
|
|
aa57997ff5 | ||
|
|
f31d6a00ec | ||
|
|
e307da36b5 | ||
|
|
be5dd68c81 | ||
|
|
e9e2e12e4e | ||
|
|
981a5915e3 | ||
|
|
224cfaf603 | ||
|
|
71f5d33af7 | ||
|
|
70f470d64e | ||
|
|
fcc6295a77 | ||
|
|
c5007f2928 | ||
|
|
62a10224a0 | ||
|
|
ee1c8ee3fa | ||
|
|
823325d049 | ||
|
|
b2cf7acfb6 | ||
|
|
c6547ac7fc | ||
|
|
748601064c | ||
|
|
a9c5be1c70 | ||
|
|
a0a6ab027f | ||
|
|
e97ae78e47 | ||
|
|
89a01afc7c | ||
|
|
9475a737f0 | ||
|
|
0225a84a81 | ||
|
|
bb15119bf0 | ||
|
|
95ae3aacb3 | ||
|
|
482a9cb04f | ||
|
|
f5dcd06838 | ||
|
|
9c8c06ef28 | ||
|
|
567ff91de0 | ||
|
|
337fe5cfaa | ||
|
|
ec81a6d157 | ||
|
|
15e6226511 | ||
|
|
80560ec20c | ||
|
|
3e1d9080df | ||
|
|
454776ecd4 | ||
|
|
dd946d4cdd | ||
|
|
a720f12e0b | ||
|
|
31f16d693b | ||
|
|
ed91ddb5a8 | ||
|
|
08a2be165c | ||
|
|
c04bfb78c6 | ||
|
|
06d8f11ca3 | ||
|
|
466d04caf7 | ||
|
|
02674f6ecb | ||
|
|
d8795e66da | ||
|
|
8cdf47f7b3 | ||
|
|
331b9133a8 | ||
|
|
783c06d811 | ||
|
|
8a4516f1ba | ||
|
|
6543728478 | ||
|
|
54347c6706 | ||
|
|
b169337fb6 | ||
|
|
b28ace970c | ||
|
|
29ca9711f8 | ||
|
|
313c0b0c80 | ||
|
|
f9ecabdccc | ||
|
|
abb1eb332d | ||
|
|
faf51de9a9 | ||
|
|
ae464b7601 | ||
|
|
79c60d34c2 | ||
|
|
fb9c1c3681 | ||
|
|
4653eb20ad | ||
|
|
c7376a59f0 | ||
|
|
09307443f9 | ||
|
|
4259533958 | ||
|
|
da87a35a69 | ||
|
|
7a468b2c16 | ||
|
|
a39549d597 | ||
|
|
a176ed2dae | ||
|
|
4ae17f65c8 | ||
|
|
be441dacd9 | ||
|
|
5210c78d5e | ||
|
|
e1bdef98d6 | ||
|
|
defd78e5c2 | ||
|
|
27944b8235 | ||
|
|
f0ef723854 | ||
|
|
889ed06acc | ||
|
|
267a0e21ba | ||
|
|
7e461f401b | ||
|
|
2ca1f33e68 | ||
|
|
dbd7c5e90b | ||
|
|
d65b74d7a0 | ||
|
|
8d6621e2a8 | ||
|
|
88957f4071 | ||
|
|
75eaec2f11 | ||
|
|
a79f28caa4 | ||
|
|
25a9ca9b90 | ||
|
|
d5a3328130 | ||
|
|
18c5cf766d | ||
|
|
1c935998fb | ||
|
|
1b1cf2a891 | ||
|
|
047a72f3da | ||
|
|
87aa6ed1da | ||
|
|
7f0fb16dc3 | ||
|
|
82f6dfbece | ||
|
|
b8d4f4e5c4 | ||
|
|
df814edafe | ||
|
|
1ec866d4dc | ||
|
|
7fce5421b4 | ||
|
|
65bd6888e8 | ||
|
|
2ca4393c5a | ||
|
|
099600cf4c | ||
|
|
4dd3fc5244 | ||
|
|
a90d9aac39 | ||
|
|
81652cf70e | ||
|
|
5f0db96fc4 | ||
|
|
2b45b9fd70 | ||
|
|
5b061ba636 | ||
|
|
1dae81b707 | ||
|
|
3ceb5fbe5b | ||
|
|
5fac731a57 | ||
|
|
d00115fc1a | ||
|
|
d2c20f97fd | ||
|
|
400e4854e8 | ||
|
|
12c66e2681 | ||
|
|
56c2115144 | ||
|
|
de6420ad59 | ||
|
|
93b03bb5ab | ||
|
|
86b68fb515 | ||
|
|
52ed248f7d | ||
|
|
bc58a2b076 | ||
|
|
fd96bb49f6 | ||
|
|
30a53670fe | ||
|
|
204f3a7397 | ||
|
|
3a6e3e0e24 | ||
|
|
3bea54136b | ||
|
|
655dc39c63 | ||
|
|
e2637ce0a7 | ||
|
|
c8c3e2bb79 | ||
|
|
ec662243d8 | ||
|
|
93b738be79 | ||
|
|
54c4e017cc | ||
|
|
1d0e6cc10e | ||
|
|
29a578ea6a | ||
|
|
905be6ffc3 | ||
|
|
2d002e5cc5 | ||
|
|
2132b50ede | ||
|
|
8d8857e552 | ||
|
|
6816c77845 | ||
|
|
2f2eb2e5b2 | ||
|
|
d2257095da | ||
|
|
53d4380339 | ||
|
|
4e9ea9aa3c | ||
|
|
a6a52ef7bb | ||
|
|
239483dfc4 | ||
|
|
e4b8707e34 | ||
|
|
c0afb2ea8f | ||
|
|
e367bd9a2e | ||
|
|
62871c8a7d | ||
|
|
9bc6fd23b9 | ||
|
|
9d762df946 | ||
|
|
e48f25d0ba | ||
|
|
20a6e0ffb6 | ||
|
|
4b39b44dab | ||
|
|
8c358948e5 | ||
|
|
3cafe20736 | ||
|
|
0014a4254d | ||
|
|
9f226fe574 | ||
|
|
e23caec9f3 | ||
|
|
64bee1b238 | ||
|
|
1b1eb1539e | ||
|
|
4bc0a786ab |
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
vendor
|
||||
26
.editorconfig
Normal file
26
.editorconfig
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
root = true
|
||||
|
||||
[*.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.blade.php]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.stub]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
# Matches the exact files either package.json or .travis.yml
|
||||
[{package.json, .travis.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -2,13 +2,16 @@
|
||||
"extends": "airbnb",
|
||||
"env": {
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
"browser": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8
|
||||
},
|
||||
"rules": {
|
||||
"camelcase": 0,
|
||||
"no-console": 0,
|
||||
"func-names": 0,
|
||||
"prefer-object-spread": 0,
|
||||
"no-param-reassign": [
|
||||
2,
|
||||
{
|
||||
|
||||
30
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
30
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. Please upload the Laravel logs as well from `storage/logs/laravel.log` (or the file with the correct date)
|
||||
|
||||
**Version**
|
||||
Please enter the version
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context and attach logs (from `storage/logs/laravel-<date>.log`)
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
10
.github/stale.yml
vendored
Normal file
10
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
daysUntilStale: 60
|
||||
daysUntilClose: false
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
exemptMilestones: true
|
||||
staleLabel: wontfix
|
||||
markComment: false
|
||||
closeComment: false
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
||||
_ide_helper.php
|
||||
.php_cs.cache
|
||||
.phpstorm.meta.php
|
||||
.phpunit.result.cache
|
||||
/vendor
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
15
.htaccess
15
.htaccess
@@ -4,8 +4,8 @@ Options -Indexes
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} ^(.*)
|
||||
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Deny all these files/folders
|
||||
RedirectMatch 403 ^/.git/.*?$
|
||||
@@ -20,6 +20,7 @@ RedirectMatch 403 ^/storage/.*?$
|
||||
RedirectMatch 403 ^/tests/.*?$
|
||||
RedirectMatch 403 ^/vendor/.*?$
|
||||
RedirectMatch 403 ^/.bowerrc$
|
||||
RedirectMatch 403 ^/.env
|
||||
RedirectMatch 403 ^/artisan$
|
||||
RedirectMatch 403 ^/composer.json
|
||||
RedirectMatch 403 ^/composer.lock
|
||||
@@ -32,12 +33,6 @@ RedirectMatch 403 ^/package.json
|
||||
RedirectMatch 403 ^/package-lock.json
|
||||
RedirectMatch 403 ^/phpunit.xml
|
||||
RedirectMatch 403 ^/webpack.mix.js
|
||||
RedirectMatch 403 ^/yarn.lock
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)/$ /$1 [L,R=301]
|
||||
|
||||
# Handle Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
RewriteRule ^(.*)$ public/$1 [L]
|
||||
|
||||
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);
|
||||
@@ -23,9 +23,8 @@ disabled:
|
||||
# - unalign_equals
|
||||
finder:
|
||||
exclude:
|
||||
- modules
|
||||
- node_modules
|
||||
- storage
|
||||
- vendor
|
||||
- node_modules
|
||||
- storage
|
||||
- vendor
|
||||
name: "*.php"
|
||||
not-name: "*.blade.php"
|
||||
|
||||
137
.travis.yml
137
.travis.yml
@@ -1,11 +1,21 @@
|
||||
#
|
||||
# Travis CI config file
|
||||
#
|
||||
|
||||
language: php
|
||||
php:
|
||||
#- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
#- nightly
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4'
|
||||
|
||||
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"
|
||||
@@ -13,45 +23,138 @@ cache:
|
||||
services:
|
||||
- mysql
|
||||
|
||||
before_script:
|
||||
- cp .travis/env.travis.php env.php
|
||||
addons:
|
||||
mariadb: '10.2'
|
||||
|
||||
install:
|
||||
- php --version
|
||||
- mysql --version
|
||||
- composer install --dev --no-interaction --verbose
|
||||
- cp .travis/env.travis.php env.php
|
||||
- cp .travis/phpunit.travis.xml phpunit.xml
|
||||
|
||||
before_script:
|
||||
- php artisan database:create --reset
|
||||
- php artisan migrate:refresh --seed
|
||||
|
||||
script:
|
||||
- php artisan database:create --reset
|
||||
- php artisan migrate:refresh --seed
|
||||
- cp .travis/phpunit.travis.xml phpunit.xml
|
||||
- vendor/bin/phpunit --debug --verbose
|
||||
- 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
|
||||
- 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/master/install | bash
|
||||
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
|
||||
|
||||
# Configure the conditional deployment
|
||||
# https://docs.travis-ci.com/user/deployment/#examples-of-conditional-deployment
|
||||
deploy:
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: ./.travis/deploy_script.sh
|
||||
on:
|
||||
all_branches: true
|
||||
php: '7.1'
|
||||
repo: nabeelio/phpvms
|
||||
php: '7.2'
|
||||
tags: false
|
||||
|
||||
# RELEASE STAGE
|
||||
# Only runs when there's a tag applied to this release (tag should be the version)
|
||||
# This uses Github Releases and posts it there (provider: releases)
|
||||
# https://docs.travis-ci.com/user/deployment/releases
|
||||
- stage: release
|
||||
script: skip
|
||||
before_deploy:
|
||||
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash
|
||||
- curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash
|
||||
- ./.travis/deploy_script.sh
|
||||
deploy:
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
api_key:
|
||||
secure: kAOYEThsSF8wM7vx+e+xWKhlvsNzhgKn1bk0zLBb7RLUM5pHIGKV/j0KrCNspwIUEPF0O594H6hCyswlpIZfxW2mTnmPqfbKxG/H2rLEAoOV0/MqzeC/gffxm7Eop6Sn4T/UC9kLSgqRynllbYtJDK6aWESdnvK3Fka0Cnpn7l/2phEf2J/nOF6QT/utpws1E0MUGqrKvX1/UYIu8np5e5aYLPOXnqahK8qzJFL4CyNBv+fhXuXfmOF4UbNbSPnrg/kY0QpUtFpz9ebvg5BjfMXJT0P4Q1BjgKBN76A7vz+ZfPmW6SqKv3o1yisXAgBWzylXh8B6pK+cUk4uXbagcGcIdkGOI6pQ5sLq+JOkBhVjSfogERePkt44KPif4EMsLRw/Jp4pTMy/vmgrON/jkbA+jXsOARTG5vAwIq4lyZzZXWUfirYwXeCfasgf+xTdo9C0cOE0jlqojO7SdF2CinDk9BduYpBTectea8Xx+YP5R1JCZNORDYynlLHKMW/8PJyAG+AsbcfKNTobQAfxw1nHa7GoKP1j4MSx1UtbulZdhmeRX/nUTFIvfgEDrl4cdBlt0/o5SuyN92DiCnvJZaYHcgXwYMvoqdXxBCnBKsM/1BZcykWi7Zt/q8krWYCOfCzBN4TDdmrKsEOUkCSOL9mI6gERHGmcGZN05PxU950=
|
||||
api_key: $GITHUB_TOKEN
|
||||
file_glob: true
|
||||
file: build/*
|
||||
on:
|
||||
tags: true
|
||||
repo: nabeelio/phpvms
|
||||
php: '7.1'
|
||||
php: '7.2'
|
||||
|
||||
@@ -2,118 +2,131 @@
|
||||
|
||||
if [ "$TRAVIS" = "true" ]; then
|
||||
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
|
||||
if test "$TRAVIS_TAG"; then
|
||||
PKG_NAME=$TRAVIS_TAG
|
||||
else
|
||||
echo "On branch $TRAVIS_BRANCH"
|
||||
if test "$TRAVIS_TAG"; then
|
||||
PKG_NAME=$TRAVIS_TAG
|
||||
VERSION=$TRAVIS_TAG
|
||||
|
||||
if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
|
||||
echo "Not on valid branch, exiting"
|
||||
exit 0;
|
||||
fi;
|
||||
# Pass in the tag as the version to write out
|
||||
php artisan phpvms:version --write $VERSION
|
||||
else
|
||||
echo "On branch $TRAVIS_BRANCH"
|
||||
|
||||
BASE_VERSION=`php artisan phpvms:version --base-only`
|
||||
PKG_NAME=${BASE_VERSION}-${TRAVIS_BRANCH}
|
||||
if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then
|
||||
echo "Not on valid branch, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FILE_NAME="phpvms-$PKG_NAME"
|
||||
TAR_NAME="$FILE_NAME.tar.gz"
|
||||
echo "Writing $TAR_NAME"
|
||||
# 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)
|
||||
|
||||
php artisan phpvms:version --write > VERSION
|
||||
VERSION=`cat VERSION`
|
||||
echo "Version: $VERSION"
|
||||
# This now includes the pre-release version, so "-dev" by default
|
||||
PKG_NAME=${BASE_VERSION}
|
||||
|
||||
echo "Cleaning files"
|
||||
# Don't pass in a version here, just write out the latest hash
|
||||
php artisan phpvms:version --write >VERSION
|
||||
VERSION=$(cat VERSION)
|
||||
fi
|
||||
|
||||
rm -rf vendor
|
||||
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||
echo "Version: $VERSION"
|
||||
echo "Package name: $TAR_NAME"
|
||||
|
||||
# Clean up the dependencies to remove some of the dev packages
|
||||
# declare -a remove_packages=(
|
||||
# 'barryvdh/laravel-ide-helper'
|
||||
# 'bpocallaghan/generators'
|
||||
# 'codedungeon/phpunit-result-printer'
|
||||
# 'fzaninotto/faker'
|
||||
# 'nikic/php-parser'
|
||||
# 'phpstan/phpstan'
|
||||
# 'phpunit/phpunit',
|
||||
# 'weebly/phpstan-laravel'
|
||||
# )
|
||||
#
|
||||
# for pkg in "${remove_packages[@]}"
|
||||
# do
|
||||
# composer --optimize-autoloader --no-interaction remove $pkg
|
||||
# done
|
||||
FILE_NAME="phpvms-$PKG_NAME"
|
||||
TAR_NAME="$FILE_NAME.tar.gz"
|
||||
|
||||
# Leftover individual files to delete
|
||||
declare -a remove_files=(
|
||||
.git
|
||||
.sass-cache
|
||||
.idea
|
||||
.travis
|
||||
tests
|
||||
_ide_helper.php
|
||||
.dpl
|
||||
.eslintignore
|
||||
.eslintrc
|
||||
.phpstorm.meta.php
|
||||
.styleci.yml
|
||||
env.php
|
||||
config.php
|
||||
Makefile
|
||||
phpunit.xml
|
||||
phpvms.iml
|
||||
Procfile
|
||||
phpstan.neon
|
||||
node_modules
|
||||
composer.phar
|
||||
vendor/willdurand/geocoder/tests
|
||||
)
|
||||
echo "Cleaning files"
|
||||
|
||||
for file in "${remove_files[@]}"
|
||||
do
|
||||
rm -rf $file
|
||||
done
|
||||
rm -rf vendor
|
||||
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||
|
||||
find ./vendor -type d -name ".git" -print0 | xargs rm -rf
|
||||
find . -type d -name "sass-cache" -print0 | xargs rm -rf
|
||||
# Leftover individual files to delete
|
||||
declare -a remove_files=(
|
||||
.git
|
||||
.github
|
||||
.sass-cache
|
||||
.idea
|
||||
.travis
|
||||
docker
|
||||
_ide_helper.php
|
||||
.dockerignore
|
||||
.dpl
|
||||
.editorconfig
|
||||
.eslintignore
|
||||
.eslintrc
|
||||
.php_cs
|
||||
.php_cs.cache
|
||||
.phpstorm.meta.php
|
||||
.styleci.yml
|
||||
.phpunit.result.cache
|
||||
env.php
|
||||
intellij_style.xml
|
||||
config.php
|
||||
docker-compose.yml
|
||||
Makefile
|
||||
phpcs.xml
|
||||
phpunit.xml
|
||||
phpvms.iml
|
||||
Procfile
|
||||
phpstan.neon
|
||||
node_modules
|
||||
composer.phar
|
||||
vendor/willdurand/geocoder/tests
|
||||
)
|
||||
|
||||
# clear any app specific stuff that might have been loaded in
|
||||
find storage/app -mindepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf {} +
|
||||
find storage/app/public -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/cache -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/sessions -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/views -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/logs -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
for file in "${remove_files[@]}"; do
|
||||
rm -rf $file
|
||||
done
|
||||
|
||||
make clean
|
||||
find ./vendor -type d -name ".git" -print0 | xargs rm -rf
|
||||
find . -type d -name "sass-cache" -print0 | xargs rm -rf
|
||||
|
||||
echo "Creating Tarball"
|
||||
cd /tmp
|
||||
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR/../ phpvms
|
||||
sha256sum $TAR_NAME > "$TAR_NAME.sha256"
|
||||
# clear any app specific stuff that might have been loaded in
|
||||
find bootstrap/cache -mindepth 1 -maxdepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/app -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf {} +
|
||||
find storage/app/public -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name avatars -not -name uploads -print0 -exec rm -rf {} +
|
||||
find storage/app/public/avatars -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/app/public/uploads -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/debugbar -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/docker -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/cache -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/sessions -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/framework/views -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
find storage/logs -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
|
||||
|
||||
echo "Uploading to S3"
|
||||
mkdir -p $TRAVIS_BUILD_DIR/build
|
||||
cd $TRAVIS_BUILD_DIR/build
|
||||
mkdir -p storage/app/public/avatars
|
||||
mkdir -p storage/app/public/uploads
|
||||
mkdir -p storage/framework/cache
|
||||
mkdir -p storage/framework/sessions
|
||||
mkdir -p storage/framework/views
|
||||
|
||||
mv "/tmp/$TAR_NAME" "/tmp/$TAR_NAME.sha256" .
|
||||
artifacts upload --target-paths "/" $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256
|
||||
# Regenerate the autoloader and classes
|
||||
composer dump-autoload
|
||||
make clean
|
||||
|
||||
# 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
|
||||
cd /tmp
|
||||
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR/../ phpvms
|
||||
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
||||
|
||||
curl -X POST --data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME ($VERSION)\"}" -H "Content-Type: application/json" $DISCORD_WEBHOOK_URL
|
||||
echo "Uploading to S3"
|
||||
mkdir -p $TRAVIS_BUILD_DIR/build
|
||||
cd $TRAVIS_BUILD_DIR/build
|
||||
|
||||
mv "/tmp/$TAR_NAME" "/tmp/$TAR_NAME.sha256" .
|
||||
artifacts upload --target-paths "/" $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_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
|
||||
|
||||
curl -X POST --data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME ($VERSION)\"}" -H "Content-Type: application/json" $DISCORD_WEBHOOK_URL
|
||||
fi
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
APP_ENV=prod
|
||||
APP_KEY=base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI=
|
||||
APP_DEBUG=true
|
||||
APP_LOG_LEVEL=debug
|
||||
APP_URL=http://localhost
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=phpvms
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
CACHE_DRIVER=array
|
||||
@@ -2,29 +2,28 @@
|
||||
exit();
|
||||
?>
|
||||
|
||||
APP_ENV=dev
|
||||
APP_KEY=base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY=
|
||||
APP_URL=http://localhost
|
||||
APP_SKIN=default
|
||||
APP_DEBUG=true
|
||||
APP_LOCALE=en
|
||||
APP_ENV="dev"
|
||||
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
|
||||
APP_URL="http://localhost"
|
||||
APP_SKIN="default"
|
||||
APP_DEBUG="true"
|
||||
APP_LOCALE="en"
|
||||
|
||||
PHPVMS_INSTALLED=true
|
||||
VACENTRAL_API_KEY=
|
||||
PHPVMS_INSTALLED="true"
|
||||
|
||||
APP_LOG=daily
|
||||
APP_LOG_LEVEL=debug
|
||||
APP_LOG_MAX_FILES=3
|
||||
APP_LOG="daily"
|
||||
APP_LOG_LEVEL="debug"
|
||||
APP_LOG_MAX_FILES="3"
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=phpvms
|
||||
DB_USERNAME=root
|
||||
DB_CONNECTION="mysql"
|
||||
DB_HOST="127.0.0.1"
|
||||
DB_PORT="3306"
|
||||
DB_DATABASE="phpvms"
|
||||
DB_USERNAME="root"
|
||||
DB_PASSWORD=
|
||||
|
||||
CACHE_DRIVER=file
|
||||
CACHE_DRIVER="file"
|
||||
CACHE_PREFIX=
|
||||
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=database
|
||||
SESSION_DRIVER="file"
|
||||
QUEUE_DRIVER="database"
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<extensions>
|
||||
<extension class="Tests\Bootstrap"/>
|
||||
</extensions>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./app</directory>
|
||||
@@ -25,5 +28,18 @@
|
||||
<ini name="error_reporting" value="E_ALL"/>
|
||||
<ini name="display_errors" value="On"/>
|
||||
<ini name="display_startup_errors" value="On"/>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
|
||||
<server name="APP_DEBUG" value="true"/>
|
||||
<server name="APP_LOG_LEVEL" value="debug"/>
|
||||
<server name="DB_CONNECTION" value="memory"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<server name="SESSION_DRIVER" value="array"/>
|
||||
<server name="QUEUE_DRIVER" value="sync"/>
|
||||
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
|
||||
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
|
||||
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
|
||||
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
|
||||
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
73
CHANGELOG.md
73
CHANGELOG.md
@@ -1,72 +1,9 @@
|
||||
## Alpha 3
|
||||
## Beta 2 (7.0.0-beta.2)
|
||||
|
||||
!! Please do a complete reinstall, with a new database
|
||||
- Switching to semver
|
||||
- PHP 7.2 minimum
|
||||
- Lots of fixes, view the [Github Milestone](https://github.com/nabeelio/phpvms/milestone/2?closed=1) for details
|
||||
|
||||
- Finances! The finance portions have been implemented, you can [read about them here](http://docs.phpvms.net/concepts/finances)
|
||||
- Awards! Added the award plugin system. [see docs](http://docs.phpvms.net/customizing/awards)
|
||||
- Import/Export in admin panel for aircraft, airports, expenses, fares, flights and subfleets
|
||||
- Changed theme system to using [laravel-theme](https://github.com/igaster/laravel-theme), there are changes to making theming much simpler with much more flexibility.
|
||||
- Added cron task for background tasks
|
||||
- Expanded on flight types to match IATA SIMM format
|
||||
- Added subfleet `cost_block_hour`
|
||||
- Fixed several security vulnerabilities (thanks magicflyer!)
|
||||
- Fuel units changed to lbs/kgs [#193](https://github.com/nabeelio/phpvms/issues/193)
|
||||
- Airports can be restricted to only hubs on registration/user profile
|
||||
- Cleaned up a lot unused icons and files [#195](https://github.com/nabeelio/phpvms/issues/195)
|
||||
- Rank restrictions for PIREPs are respected [#170](https://github.com/nabeelio/phpvms/issues/170)
|
||||
- API: Added the ability to get/update/delete user bids [#172](https://github.com/nabeelio/phpvms/issues/172)
|
||||
- API: Added `block_time` parameter for PIREP prefile/update/file calls
|
||||
- API: Added `block_on_time` and `block_off_time` for PIREP prefile/update/file calls
|
||||
- Artisan: Added a `phpvms:csv-import [table] [file]` to import from CSV
|
||||
- Artisan: Added a `phpvms:yaml-export [tables]` to export tables to YAML files which can be re-imported using `phpvms:yaml-import`
|
||||
- Numerous bug fixes
|
||||
|
||||
## Alpha 2 (2018-02-23, v7.0.0-alpha2)
|
||||
|
||||
!! Please do a full reinstall, with recreating the database
|
||||
|
||||
- Bump minimum PHP version to 7.1, since 7.0 is already deprecated - [#166](https://github.com/nabeelio/phpvms/issues/166)
|
||||
- Upgraded to Laravel 5.6
|
||||
- Installer: Updated to create `config.php` file, to override config file values without having to modify the config files themselves
|
||||
- Installer: Moved most options into the `config.php`, out of the `env.php` file
|
||||
- Admin: Set the country for the airline [#191](https://github.com/nabeelio/phpvms/issues/191)
|
||||
- Admin: Add ranks from the subfleet edit page
|
||||
- Admin: Added flight time field to flight add/edit page
|
||||
- Admin: PIREP hours can't be changed after it's no longer in a pending state
|
||||
- Admin: Removed the tail number field
|
||||
- DB: `airport.tz` to `airport.timezone`
|
||||
- DB: Removed `aircaft.tail_number`
|
||||
- DB: Decimal type field sizes shrunk to the default sizes
|
||||
- DB: Removed the `raw_data` field from the PIREPs table
|
||||
- API: All units expected in imperial (distance in nautical miles, fuel in lbs, mass in lbs)
|
||||
- API: Added ability to add/remove bids for users
|
||||
- API: Added a setting to only show aircraft that are at the departure airport of a flight [#171](https://github.com/nabeelio/phpvms/issues/171)
|
||||
- API: Most calls, with exception of ACARS, are now private and require an API key to access [#173](https://github.com/nabeelio/phpvms/issues/173)
|
||||
- API: Create an `/api/flight/:id/route` call to return the route information for a flight [#183](https://github.com/nabeelio/phpvms/issues/183)
|
||||
- API: Allow a `fields` object to set custom PIREP fields, also returns the current values
|
||||
- API: `level` not required in prefile anymore
|
||||
- Setting: Restrict to aircraft that are at a flight's departure airport [#171](https://github.com/nabeelio/phpvms/issues/171)
|
||||
- Setting: Implementation of filtering flights that are only at the user's current airport [#174](https://github.com/nabeelio/phpvms/issues/174)
|
||||
- Templates: Add a `SKIN_NAME` template variable to reference the current skin, vs hardcoding the skin name in the templates
|
||||
- Console: Added `php artisan phpvms:dev-install` command which creates the config files and creates the database/inserts sample data in one command [#176](https://github.com/nabeelio/phpvms/issues/176)
|
||||
- Rank aircraft restrictions are properly working now [#170](https://github.com/nabeelio/phpvms/issues/170)
|
||||
|
||||
#### Fixes
|
||||
|
||||
- PIREP fields being set when filing manually is working
|
||||
- ACARS data wasn't being ordered properly, causing issues on the map [77055991](https://github.com/nabeelio/phpvms/commit/77055991af36877552e1921466987d3066774d6b)
|
||||
- Field for the rank's image changed to string input [b5dbde8](https://github.com/nabeelio/phpvms/commit/b5dbde84c4c786799f474117381b8227642f0777)
|
||||
- Set a default value for a setting [#106](https://github.com/nabeelio/phpvms/issues/106)
|
||||
- Admin: Rank image field fixed
|
||||
- API: Only active airlines are returned
|
||||
- API; Return errors if user isn't allowed on the submitted aircraft [#170](https://github.com/nabeelio/phpvms/issues/170)
|
||||
- API: Fixed typo from `subfleet` to `subfleets` in the `/api/flights` call(s) [f6b2102](https://github.com/nabeelio/phpvms/commit/f6b2102e4827da6177eb4eee0c3ce0d38eb78ce3)
|
||||
- API: Wrapped all calls in a `data` field
|
||||
- API: `planned_distance` and `planned_flight_time` fields are now optional
|
||||
- Setting: Subfleets returned in the flight calls respect the `pireps.restrict_aircraft_to_rank` setting [#170](https://github.com/nabeelio/phpvms/issues/170)
|
||||
|
||||
------
|
||||
|
||||
## Alpha 1 (2018-02-04, v7.0.0-alpha1)
|
||||
## Beta 1 (v7.0.0-beta)
|
||||
|
||||
- Initial Release
|
||||
|
||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
WORKDIR /var/www/
|
||||
|
||||
RUN apk add gmp-dev
|
||||
RUN curl --silent --show-error https://getcomposer.org/installer | php
|
||||
|
||||
# Copy any config files in
|
||||
COPY resources/docker/php/ext-opcache.ini $PHP_INI_DIR/conf.d/
|
||||
COPY resources/docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
|
||||
RUN ln -sf /dev/stderr /var/log/fpm-error.log
|
||||
|
||||
RUN docker-php-ext-install \
|
||||
calendar \
|
||||
pdo_mysql \
|
||||
gmp \
|
||||
opcache && \
|
||||
docker-php-ext-enable pdo_mysql opcache
|
||||
|
||||
COPY . /var/www/
|
||||
RUN php composer.phar install \
|
||||
--ignore-platform-reqs \
|
||||
--no-interaction \
|
||||
--no-plugins \
|
||||
--no-scripts \
|
||||
--prefer-dist
|
||||
|
||||
EXPOSE 9000
|
||||
28
Makefile
28
Makefile
@@ -19,7 +19,7 @@ clean:
|
||||
@php artisan view:clear
|
||||
@find bootstrap/cache -type f -not -name '.gitignore' -print0 | xargs -0 rm -rf
|
||||
|
||||
@find storage/framework/cache/ -mindepth 1 -not -name '.gitignore' -print0 | xargs -0 rm -rf
|
||||
@find storage/framework/cache/ -mindepth 1 -type f -not -name '.gitignore' -print0 | xargs -0 rm -rf
|
||||
@find storage/framework/sessions/ -mindepth 1 -type f -not -name '.gitignore' -print0 | xargs -0 rm -rf
|
||||
@find storage/framework/views/ -mindepth 1 -not -name '.gitignore' -print0 | xargs -0 rm -rf
|
||||
|
||||
@@ -29,6 +29,13 @@ clean:
|
||||
clean-routes:
|
||||
@php artisan route:clear
|
||||
|
||||
.PHONY: clear
|
||||
clear:
|
||||
@php artisan cache:clear
|
||||
@php artisan config:clear
|
||||
@php artisan route:clear
|
||||
@php artisan view:clear
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
@php $(COMPOSER) install --no-interaction
|
||||
@@ -36,7 +43,7 @@ build:
|
||||
# This is to build all the stylesheets, etc
|
||||
.PHONY: build-assets
|
||||
build-assets:
|
||||
yarn run dev
|
||||
yarn run production
|
||||
|
||||
.PHONY: install
|
||||
install: build
|
||||
@@ -52,13 +59,16 @@ update: build
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: reset
|
||||
reset: cleanapp/Models/Traits/JournalTrait.php
|
||||
reset: clean
|
||||
@php $(COMPOSER) dump-autoload
|
||||
@make reload-db
|
||||
|
||||
.PHONY: reload-db
|
||||
reload-db:
|
||||
@php artisan phpvms:dev-install --reset-db
|
||||
@php artisan database:create --reset
|
||||
@php artisan migrate --seed
|
||||
@echo "Done!"
|
||||
@make clean
|
||||
|
||||
.PHONY: tests
|
||||
tests: test
|
||||
@@ -68,9 +78,13 @@ test:
|
||||
#php artisan database:create --reset
|
||||
vendor/bin/phpunit --debug --verbose
|
||||
|
||||
.PHONY:
|
||||
phpstan:
|
||||
vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app
|
||||
.PHONY: phpcs
|
||||
phpcs:
|
||||
@vendor/bin/php-cs-fixer fix --config=.php_cs -v --diff --dry-run
|
||||
|
||||
#.PHONY: phpstan
|
||||
#phpstan:
|
||||
# vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app
|
||||
|
||||
.PHONY: replay-acars
|
||||
replay-acars:
|
||||
|
||||
4
Procfile
4
Procfile
@@ -1,5 +1,5 @@
|
||||
dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground
|
||||
#dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground
|
||||
php-fpm: /usr/local/sbin/php-fpm --nodaemonize
|
||||
nginx: /usr/local/bin/nginx -g 'daemon off;'
|
||||
#mysql: /usr/local/bin/mysqld
|
||||
mysql: docker-compose --file ~/docker/mysql/docker-compose.yml up
|
||||
#mailhog: /usr/local/bin/mailhog
|
||||
|
||||
36
README.md
36
README.md
@@ -2,16 +2,15 @@
|
||||
|
||||
[](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. If you're looking for
|
||||
the old, phpVMS classic, it's [available here](https://github.com/nabeelio/phpvms_v2).
|
||||
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
|
||||
|
||||
A full distribution, with all of the composer dependencies, is available at this
|
||||
[GitHub Releases](https://github.com/nabeelio/phpvms/releases) link.
|
||||
|
||||
The latest documentation, with installation instructions is available
|
||||
[on the phpVMS documentation](http://docs.phpvms.net/) page.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -30,6 +29,33 @@ The latest documentation, with installation instructions is available
|
||||
## Installer
|
||||
|
||||
1. Upload to your server
|
||||
2. Visit the site, and follow the link to the installer
|
||||
1. Visit the site, and follow the link to the installer
|
||||
|
||||
[View installation details](http://docs.phpvms.net/setup/installation)
|
||||
|
||||
# development environment
|
||||
|
||||
A full development environment can be brought up using Docker:
|
||||
|
||||
```bash
|
||||
composer install
|
||||
yarn install
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
Then go to `http://localhost`. If you're using dnsmasq, the `app` container is listening on `phpvms.test`, or you can add to your `/etc/hosts` file:
|
||||
|
||||
```
|
||||
127.0.0.1 phpvms.test
|
||||
```
|
||||
|
||||
## Building JS/CSS assets
|
||||
|
||||
Yarn is required, run:
|
||||
|
||||
```bash
|
||||
make build-assets
|
||||
```
|
||||
|
||||
This will build all of the assets according to the webpack file.
|
||||
|
||||
@@ -5,13 +5,11 @@ namespace App\Bootstrap;
|
||||
use Illuminate\Contracts\Config\Repository as RepositoryContract;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
/**
|
||||
* Class LoadConfiguration
|
||||
*/
|
||||
class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfiguration
|
||||
{
|
||||
/**
|
||||
* Load the configuration items from all of the files.
|
||||
* Load the configuration items from all of the files. This reads the config.php from
|
||||
* that's sitting in the root, and then recursively merges it with the current configs
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Config\Repository $repository
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Facades\Utils;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
/**
|
||||
* Class AcarsReplay
|
||||
*/
|
||||
class AcarsReplay extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:replay {files} {--manual} {--write-all} {--no-submit}';
|
||||
@@ -172,7 +169,7 @@ class AcarsReplay extends Command
|
||||
* @var $flights Collection
|
||||
*/
|
||||
$flights = collect($files)->transform(function ($f) {
|
||||
$file = storage_path('/replay/'.$f.'.json');
|
||||
$file = $f;
|
||||
if (file_exists($file)) {
|
||||
$this->info('Loading '.$file);
|
||||
$contents = file_get_contents($file);
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use Artisan;
|
||||
use App\Contracts\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/**
|
||||
* Class ComposerCommand
|
||||
*/
|
||||
class ComposerCommand extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:composer {cmd}';
|
||||
|
||||
95
app/Console/Commands/CreateConfigs.php
Normal file
95
app/Console/Commands/CreateConfigs.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App;
|
||||
use App\Contracts\Command;
|
||||
use App\Services\Installer\SeederService;
|
||||
use DatabaseSeeder;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
|
||||
/**
|
||||
* Create the config files
|
||||
*/
|
||||
class CreateConfigs extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:config {db_host} {db_name} {db_user} {db_pass}';
|
||||
protected $description = 'Create the config files';
|
||||
|
||||
private $databaseSeeder;
|
||||
private $seederSvc;
|
||||
|
||||
public function __construct(DatabaseSeeder $databaseSeeder, SeederService $seederSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->databaseSeeder = $databaseSeeder;
|
||||
$this->seederSvc = $seederSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*
|
||||
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->writeConfigs();
|
||||
|
||||
// Reload the configuration
|
||||
App::boot();
|
||||
|
||||
$this->info('Recreating database');
|
||||
$this->call('database:create', [
|
||||
'--reset' => true,
|
||||
]);
|
||||
|
||||
$this->info('Running migrations');
|
||||
$this->call('migrate:fresh', [
|
||||
'--seed' => true,
|
||||
]);
|
||||
|
||||
$this->seederSvc->syncAllSeeds();
|
||||
|
||||
$this->info('Done!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrite the configuration files
|
||||
*
|
||||
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
|
||||
*/
|
||||
protected function writeConfigs()
|
||||
{
|
||||
/** @var ConfigService $cfgSvc */
|
||||
$cfgSvc = app(ConfigService::class);
|
||||
|
||||
$this->info('Removing the old config files');
|
||||
|
||||
// Remove the old files
|
||||
$config_file = base_path('config.php');
|
||||
if (file_exists($config_file)) {
|
||||
unlink($config_file);
|
||||
}
|
||||
|
||||
$env_file = base_path('env.php');
|
||||
if (file_exists($env_file)) {
|
||||
unlink($env_file);
|
||||
}
|
||||
|
||||
//{name} {db_host} {db_name} {db_user} {db_pass}
|
||||
|
||||
$this->info('Regenerating the config files');
|
||||
$cfgSvc->createConfigFiles([
|
||||
'APP_ENV' => 'dev',
|
||||
'SITE_NAME' => $this->argument('name'),
|
||||
'DB_CONN' => 'mysql',
|
||||
'DB_HOST' => $this->argument('db_host'),
|
||||
'DB_NAME' => $this->argument('db_name'),
|
||||
'DB_USER' => $this->argument('db_user'),
|
||||
'DB_PASS' => $this->argument('db_pass'),
|
||||
]);
|
||||
|
||||
$this->info('Config files generated!');
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use Log;
|
||||
use App\Console\Services\Database;
|
||||
use App\Contracts\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Tivie\OS\Detector;
|
||||
|
||||
/**
|
||||
* Class CreateDatabase
|
||||
*/
|
||||
class CreateDatabase extends Command
|
||||
{
|
||||
protected $signature = 'database:create {--reset} {--conn=?}';
|
||||
protected $signature = 'database:create {--reset} {--migrate} {--conn=?}';
|
||||
protected $description = 'Create a database';
|
||||
protected $os;
|
||||
|
||||
@@ -20,7 +19,7 @@ class CreateDatabase extends Command
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->os = new \Tivie\OS\Detector();
|
||||
$this->os = new Detector();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,8 +37,7 @@ class CreateDatabase extends Command
|
||||
$user = config($dbkey.'username');
|
||||
$pass = config($dbkey.'password');
|
||||
|
||||
$dbSvc = new \App\Console\Services\Database();
|
||||
|
||||
$dbSvc = new Database();
|
||||
$dsn = $dbSvc->createDsn($host, $port);
|
||||
Log::info('Connection string: '.$dsn);
|
||||
|
||||
|
||||
@@ -2,20 +2,23 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Services\AirportService;
|
||||
use App\Services\AwardService;
|
||||
use App\Services\DatabaseService;
|
||||
use DB;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use PDO;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Class DevCommands
|
||||
*/
|
||||
class DevCommands extends Command
|
||||
{
|
||||
protected $signature = 'phpvms {cmd} {param?}';
|
||||
@@ -30,6 +33,7 @@ class DevCommands extends Command
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbSvc = $dbSvc;
|
||||
}
|
||||
|
||||
@@ -46,13 +50,17 @@ class DevCommands extends Command
|
||||
}
|
||||
|
||||
$commands = [
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'manual-insert' => 'manualInsert',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'live-flights' => 'liveFlights',
|
||||
'manual-insert' => 'manualInsert',
|
||||
'metar' => 'getMetar',
|
||||
'recalculate-stats' => 'recalculateStats',
|
||||
'reset-install' => 'resetInstall',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
];
|
||||
|
||||
if (!array_key_exists($command, $commands)) {
|
||||
@@ -183,6 +191,19 @@ class DevCommands extends Command
|
||||
$this->info('Writing yaml to storage: '.$file_name);
|
||||
}
|
||||
|
||||
protected function getMetar(): void
|
||||
{
|
||||
$icao = $this->argument('param');
|
||||
if (!$icao) {
|
||||
$this->error('Enter an ICAO!');
|
||||
exit();
|
||||
}
|
||||
|
||||
$airportSvc = app(AirportService::class);
|
||||
$metar = $airportSvc->getMetar($icao);
|
||||
$this->info($metar->raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the rows from the file, manually advancing each row
|
||||
*/
|
||||
@@ -212,4 +233,68 @@ class DevCommands extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate the stats for all users
|
||||
*/
|
||||
protected function recalculateStats(): void
|
||||
{
|
||||
$userSvc = app(UserService::class);
|
||||
$userSvc->recalculateAllUserStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all of the tables, etc from the database, for a clean install
|
||||
*/
|
||||
protected function resetInstall(): void
|
||||
{
|
||||
$confirm = $this->ask('This will erase your entire install and database, are you sure? y/n ');
|
||||
if (strtolower($confirm) !== 'y') {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
if (config('database.default') === 'mysql') {
|
||||
DB::statement('SET foreign_key_checks=0');
|
||||
}
|
||||
|
||||
$this->info('Dropping all tables');
|
||||
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
|
||||
foreach ($tables as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
$this->error('DB error: '.$e->getMessage());
|
||||
}
|
||||
|
||||
$this->info('Deleting config file');
|
||||
|
||||
try {
|
||||
unlink('config.php');
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
$this->info('Deleting env file');
|
||||
|
||||
try {
|
||||
unlink('env.php');
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
$this->info('Clearing caches');
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('route:clear');
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('view:clear');
|
||||
|
||||
$this->info('Done!');
|
||||
}
|
||||
|
||||
public function liveFlights(): void
|
||||
{
|
||||
$acarsRepo = app(AcarsRepository::class);
|
||||
$flights = $acarsRepo->getPositions(setting('acars.live_time'))->toArray();
|
||||
|
||||
dd($flights);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
|
||||
/**
|
||||
@@ -13,13 +13,14 @@ class DevInstall extends Command
|
||||
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
|
||||
protected $description = 'Run a developer install and run the sample migration';
|
||||
|
||||
/**
|
||||
* The YAML files with sample data to import
|
||||
*/
|
||||
protected $yaml_imports = [
|
||||
'sample.yml',
|
||||
'acars.yml',
|
||||
];
|
||||
private $databaseSeeder;
|
||||
|
||||
public function __construct(\DatabaseSeeder $databaseSeeder)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->databaseSeeder = $databaseSeeder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
@@ -45,16 +46,6 @@ class DevInstall extends Command
|
||||
'--seed' => true,
|
||||
]);
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
$this->info('Importing sample data');
|
||||
foreach ($this->yaml_imports as $yml) {
|
||||
$this->call('phpvms:yaml-import', [
|
||||
'files' => ['app/Database/seeds/'.$yml],
|
||||
]);
|
||||
}
|
||||
|
||||
$this->info('Done!');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Services\ImportService;
|
||||
|
||||
/**
|
||||
* Class ImportCsv
|
||||
*/
|
||||
class ImportCsv extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:csv-import {type} {file}';
|
||||
@@ -23,6 +20,7 @@ class ImportCsv extends Command
|
||||
public function __construct(ImportService $importer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->importer = $importer;
|
||||
}
|
||||
|
||||
@@ -36,11 +34,11 @@ class ImportCsv extends Command
|
||||
$type = $this->argument('type');
|
||||
$file = $this->argument('file');
|
||||
|
||||
if (\in_array($type, ['flight', 'flights'])) {
|
||||
if (\in_array($type, ['flight', 'flights'], true)) {
|
||||
$status = $this->importer->importFlights($file);
|
||||
} elseif ($type === 'aircraft') {
|
||||
$status = $this->importer->importAircraft($file);
|
||||
} elseif (\in_array($type, ['airport', 'airports'])) {
|
||||
} elseif (\in_array($type, ['airport', 'airports'], true)) {
|
||||
$status = $this->importer->importAirports($file);
|
||||
} elseif ($type === 'subfleet') {
|
||||
$status = $this->importer->importSubfleets($file);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
|
||||
class ImportFromClassic extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:importer {db_host} {db_name} {db_user} {db_pass?} {table_prefix=phpvms_}';
|
||||
protected $description = 'Import from an older version of phpVMS';
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$db_creds = [
|
||||
'host' => $this->argument('db_host'),
|
||||
'name' => $this->argument('db_name'),
|
||||
'user' => $this->argument('db_user'),
|
||||
'pass' => $this->argument('db_pass'),
|
||||
'table_prefix' => $this->argument('table_prefix'),
|
||||
];
|
||||
|
||||
$importerSvc = new \App\Console\Services\Importer($db_creds);
|
||||
$importerSvc->run();
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Models\Enums\NavaidType;
|
||||
use App\Models\Navdata;
|
||||
|
||||
/**
|
||||
* Class NavdataImport
|
||||
*/
|
||||
class NavdataImport extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:navdata';
|
||||
|
||||
52
app/Console/Commands/PirepExport.php
Normal file
52
app/Console/Commands/PirepExport.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Contracts\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class PirepExport extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:pirep-export {id}';
|
||||
protected $description = 'PIREP table export';
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$pirep_id = $this->argument('id');
|
||||
if (empty($pirep_id)) {
|
||||
$this->error('No PIREP ID specified');
|
||||
exit();
|
||||
}
|
||||
|
||||
// List the tables to export and the column name for the pirep id
|
||||
$tables = [
|
||||
'pireps' => 'id',
|
||||
'acars' => 'pirep_id',
|
||||
'pirep_comments' => 'pirep_id',
|
||||
'pirep_fares' => 'pirep_id',
|
||||
'pirep_field_values' => 'pirep_id',
|
||||
'expenses' => 'ref_model_id',
|
||||
'journal_transactions' => 'ref_model_id',
|
||||
];
|
||||
|
||||
$export_tables = [];
|
||||
foreach ($tables as $table => $key) {
|
||||
$export_tables[$table] = [];
|
||||
|
||||
$rows = DB::table($table)
|
||||
->where($key, '=', $pirep_id)
|
||||
->get();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$export_tables[$table][] = (array) $row;
|
||||
}
|
||||
}
|
||||
|
||||
$yaml = Yaml::dump($export_tables, 4, 2);
|
||||
echo $yaml;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
/**
|
||||
* Class TestApi
|
||||
*/
|
||||
class TestApi extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:test-api {apikey} {url}';
|
||||
|
||||
@@ -2,33 +2,21 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Services\VersionService;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Class Version
|
||||
*/
|
||||
class Version extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:version {--write} {--base-only}';
|
||||
protected $signature = 'phpvms:version {--write} {--base-only} {--write-full-version} {version?}';
|
||||
|
||||
/**
|
||||
* Create the version number that gets written out
|
||||
*
|
||||
* @param mixed $cfg
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function createVersionNumber($cfg)
|
||||
private $versionSvc;
|
||||
|
||||
public function __construct(VersionService $versionSvc)
|
||||
{
|
||||
exec($cfg['git']['git-local'], $version);
|
||||
$version = substr($version[0], 0, $cfg['build']['length']);
|
||||
parent::__construct();
|
||||
|
||||
// prefix with the date in YYMMDD format
|
||||
$date = date('ymd');
|
||||
$version = $date.'-'.$version;
|
||||
|
||||
return $version;
|
||||
$this->versionSvc = $versionSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,27 +26,39 @@ class Version extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$version_file = config_path('version.yml');
|
||||
$cfg = Yaml::parse(file_get_contents($version_file));
|
||||
|
||||
// Get the current build id
|
||||
$build_number = $this->createVersionNumber($cfg);
|
||||
$cfg['build']['number'] = $build_number;
|
||||
|
||||
$c = $cfg['current'];
|
||||
$version = "v{$c['major']}.{$c['minor']}.{$c['patch']}-{$build_number}";
|
||||
|
||||
if ($this->option('write')) {
|
||||
// Write the updated build number out to the file
|
||||
$version_file = config_path('version.yml');
|
||||
$cfg = Yaml::parse(file_get_contents($version_file));
|
||||
|
||||
// If a version is being passed in, the update the build, etc data against this
|
||||
if ($this->argument('version')) {
|
||||
$version = \SemVer\SemVer\Version::fromString($this->argument('version'));
|
||||
if ($this->option('write_full_version')) {
|
||||
$cfg['current']['major'] = $version->getMajor();
|
||||
$cfg['current']['minor'] = $version->getMinor();
|
||||
$cfg['current']['patch'] = $version->getPatch();
|
||||
}
|
||||
|
||||
$prerelease = $version->getPreRelease();
|
||||
if (strpos($prerelease, '.') !== false) {
|
||||
$prerelease = explode('.', $prerelease);
|
||||
$cfg['current']['prerelease'] = $prerelease[0];
|
||||
$cfg['current']['buildmetadata'] = $prerelease[1];
|
||||
} else {
|
||||
$cfg['current']['prerelease'] = $prerelease;
|
||||
}
|
||||
}
|
||||
|
||||
// Always write out the build ID/build number which is the commit hash
|
||||
$build_number = $this->versionSvc->getBuildId($cfg);
|
||||
$cfg['current']['commit'] = $build_number;
|
||||
$cfg['build']['number'] = $build_number;
|
||||
|
||||
file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
|
||||
}
|
||||
|
||||
// Only show the major.minor.patch version
|
||||
if ($this->option('base-only')) {
|
||||
$version = 'v'.$cfg['current']['major'].'.'
|
||||
.$cfg['current']['minor'].'.'
|
||||
.$cfg['current']['patch'];
|
||||
}
|
||||
|
||||
$version = $this->versionSvc->getCurrentVersion(!$this->option('base-only'));
|
||||
echo $version."\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Services\DatabaseService;
|
||||
use App\Contracts\Command;
|
||||
use DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
@@ -15,16 +14,6 @@ class YamlExport extends Command
|
||||
protected $signature = 'phpvms:yaml-export {tables*}';
|
||||
protected $description = 'YAML table export';
|
||||
|
||||
/**
|
||||
* YamlExport constructor.
|
||||
*
|
||||
* @param DatabaseService $dbSvc
|
||||
*/
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Services\DatabaseService;
|
||||
|
||||
/**
|
||||
@@ -22,6 +22,7 @@ class YamlImport extends Command
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbSvc = $dbSvc;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Events\CronHourly;
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ class Hourly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronHourly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Events\CronMonthly;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ class Monthly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronMonthly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Events\CronNightly;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ class Nightly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronNightly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Contracts\Command;
|
||||
use App\Events\CronWeekly;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ class Weekly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronWeekly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ use App\Console\Cron\Hourly;
|
||||
use App\Console\Cron\Monthly;
|
||||
use App\Console\Cron\Nightly;
|
||||
use App\Console\Cron\Weekly;
|
||||
use App\Services\CronService;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
/**
|
||||
* Class Kernel
|
||||
*/
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
@@ -27,6 +25,14 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command(Weekly::class)->weeklyOn(0);
|
||||
$schedule->command(Monthly::class)->monthlyOn(1);
|
||||
$schedule->command(Hourly::class)->hourly();
|
||||
|
||||
// When spatie-backups runs
|
||||
$schedule->command('backup:clean')->daily()->at('01:00');
|
||||
$schedule->command('backup:run')->daily()->at('02:00');
|
||||
|
||||
// Update the last time the cron was run
|
||||
$cronSvc = app(CronService::class);
|
||||
$cronSvc->updateLastRunTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +42,6 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
require app_path('Routes/console.php');
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__.'/Cron');
|
||||
}
|
||||
|
||||
@@ -1,695 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Services;
|
||||
|
||||
use App\Facades\Utils;
|
||||
use App\Models\Aircraft;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Airport;
|
||||
use App\Models\Enums\FlightType;
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\Rank;
|
||||
use App\Models\Subfleet;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
/**
|
||||
* Class Importer
|
||||
* TODO: Batch import
|
||||
*/
|
||||
class Importer
|
||||
{
|
||||
/**
|
||||
* Hold references
|
||||
*/
|
||||
private $mappedEntities = [];
|
||||
|
||||
/**
|
||||
* Hold the PDO connection to the old database
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $creds;
|
||||
|
||||
/**
|
||||
* Hold the instance of the console logger
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
private $log;
|
||||
|
||||
/**
|
||||
* CONSTANTS
|
||||
*/
|
||||
public const BATCH_READ_ROWS = 300;
|
||||
public const SUBFLEET_NAME = 'Imported Aircraft';
|
||||
|
||||
/**
|
||||
* Importer constructor.
|
||||
*
|
||||
* @param $db_creds
|
||||
*/
|
||||
public function __construct($db_creds)
|
||||
{
|
||||
// Setup the logger
|
||||
$this->log = new ConsoleOutput();
|
||||
|
||||
// The db credentials
|
||||
$this->creds = array_merge([
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'name' => '',
|
||||
'user' => '',
|
||||
'pass' => '',
|
||||
'table_prefix' => 'phpvms_',
|
||||
], $db_creds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->reconnect();
|
||||
|
||||
// Import all the different parts
|
||||
$this->importRanks();
|
||||
$this->importAirlines();
|
||||
$this->importAircraft();
|
||||
$this->importAirports();
|
||||
|
||||
$this->importUsers();
|
||||
$this->importFlights();
|
||||
$this->importPireps();
|
||||
|
||||
// Finish up
|
||||
$this->findLastPireps();
|
||||
$this->recalculateRanks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnect to the old phpVMS DB using PDO
|
||||
*/
|
||||
protected function reconnect()
|
||||
{
|
||||
$dsn = 'mysql:'.implode(';', [
|
||||
'host='.$this->creds['host'],
|
||||
'port='.$this->creds['port'],
|
||||
'dbname='.$this->creds['name'],
|
||||
]);
|
||||
|
||||
$this->info('Connection string: '.$dsn);
|
||||
|
||||
try {
|
||||
$this->conn = new PDO($dsn, $this->creds['user'], $this->creds['pass']);
|
||||
$this->conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
|
||||
} catch (\PDOException $e) {
|
||||
$this->error($e);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
*/
|
||||
protected function comment($message)
|
||||
{
|
||||
$this->log->writeln('<comment>'.$message.'</comment>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
*/
|
||||
protected function error($message)
|
||||
{
|
||||
$this->log->writeln('<error>'.$message.'</error>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $message
|
||||
*/
|
||||
protected function info($message)
|
||||
{
|
||||
if (\is_array($message)) {
|
||||
/* @noinspection ForgottenDebugOutputInspection */
|
||||
print_r($message);
|
||||
} else {
|
||||
$this->log->writeln('<info>'.$message.'</info>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table name with the prefix
|
||||
*
|
||||
* @param $table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function tableName($table)
|
||||
{
|
||||
if ($this->creds['table_prefix'] !== false) {
|
||||
return $this->creds['table_prefix'].$table;
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function saveModel($model)
|
||||
{
|
||||
try {
|
||||
$model->save();
|
||||
|
||||
return true;
|
||||
} catch (QueryException $e) {
|
||||
if ($e->getCode() !== '23000') {
|
||||
$this->error($e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new mapping between an old ID and the new one
|
||||
*
|
||||
* @param $entity
|
||||
* @param $old_id
|
||||
* @param $new_id
|
||||
*/
|
||||
protected function addMapping($entity, $old_id, $new_id)
|
||||
{
|
||||
if (!array_key_exists($entity, $this->mappedEntities)) {
|
||||
$this->mappedEntities[$entity] = [];
|
||||
}
|
||||
|
||||
$this->mappedEntities[$entity][$old_id] = $new_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID for a mapping
|
||||
*
|
||||
* @param $entity
|
||||
* @param $old_id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function getMapping($entity, $old_id)
|
||||
{
|
||||
if (!array_key_exists($entity, $this->mappedEntities)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$entity = $this->mappedEntities[$entity];
|
||||
if (array_key_exists($old_id, $entity)) {
|
||||
return $entity[$old_id];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $date
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
protected function parseDate($date)
|
||||
{
|
||||
$carbon = Carbon::parse($date);
|
||||
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a decimal duration and convert it to minutes
|
||||
*
|
||||
* @param $duration
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
protected function convertDuration($duration)
|
||||
{
|
||||
if (strpos($duration, '.') !== false) {
|
||||
$delim = '.';
|
||||
} elseif (strpos($duration, ':')) {
|
||||
$delim = ':';
|
||||
} else {
|
||||
// no delimiter, assume it's just a straight hour
|
||||
return (int) $duration * 60;
|
||||
}
|
||||
|
||||
$hm = explode($delim, $duration);
|
||||
$hours = (int) $hm[0] * 60;
|
||||
$mins = (int) $hm[1];
|
||||
|
||||
return $hours + $mins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $table
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTotalRows($table)
|
||||
{
|
||||
$table = $this->tableName($table);
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM '.$table;
|
||||
$rows = $this->conn->query($sql)->fetchColumn();
|
||||
|
||||
$this->info('Found '.$rows.' rows in '.$table);
|
||||
|
||||
return (int) $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all the rows in a table, but read them in a batched manner
|
||||
*
|
||||
* @param string $table The name of the table
|
||||
* @param null $read_rows Number of rows to read
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
protected function readRows($table, $read_rows = null)
|
||||
{
|
||||
// Set the table prefix if it has been entered
|
||||
$this->tableName($table);
|
||||
|
||||
$offset = 0;
|
||||
if ($read_rows === null) {
|
||||
$read_rows = self::BATCH_READ_ROWS;
|
||||
}
|
||||
|
||||
$total_rows = $this->getTotalRows($table);
|
||||
|
||||
while ($offset < $total_rows) {
|
||||
$rows_to_read = $offset + $read_rows;
|
||||
if ($rows_to_read > $total_rows) {
|
||||
$rows_to_read = $total_rows;
|
||||
}
|
||||
|
||||
$this->info('Reading '.$offset.' to '.$rows_to_read.' of '.$total_rows);
|
||||
|
||||
$sql = 'SELECT * FROM '.$this->tableName($table)
|
||||
.' LIMIT '.self::BATCH_READ_ROWS.' OFFSET '.$offset;
|
||||
|
||||
try {
|
||||
foreach ($this->conn->query($sql) as $row) {
|
||||
yield $row;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Without incrementing the offset, it should re-run the same query
|
||||
$this->error($e);
|
||||
|
||||
if (strpos($e->getMessage(), 'server has gone away') !== false) {
|
||||
$this->reconnect();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$offset += self::BATCH_READ_ROWS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the subfleet
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getSubfleet()
|
||||
{
|
||||
$airline = Airline::first();
|
||||
$subfleet = Subfleet::firstOrCreate(
|
||||
['airline_id' => $airline->id, 'name' => self::SUBFLEET_NAME],
|
||||
['type' => 'PHPVMS']
|
||||
);
|
||||
|
||||
return $subfleet;
|
||||
}
|
||||
|
||||
/**
|
||||
* All the individual importers, done on a per-table basis
|
||||
* Some tables get saved locally for tables that use FK refs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import all of the ranks
|
||||
*/
|
||||
protected function importRanks()
|
||||
{
|
||||
$this->comment('--- RANK IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('ranks') as $row) {
|
||||
$rank = Rank::firstOrCreate(
|
||||
['name' => $row->rank],
|
||||
['image_url' => $row->rankimage, 'hours' => $row->minhours]
|
||||
);
|
||||
|
||||
$this->addMapping('ranks', $row->rankid, $rank->id);
|
||||
$this->addMapping('ranks', $row->rank, $rank->id);
|
||||
|
||||
if ($rank->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' ranks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Import all of the airlines. Save them all in the private var $airlines
|
||||
* They're used to lookup from other reference tables
|
||||
*/
|
||||
protected function importAirlines()
|
||||
{
|
||||
$this->comment('--- AIRLINE IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('airlines') as $row) {
|
||||
$airline = Airline::firstOrCreate(
|
||||
['icao' => $row->code],
|
||||
['iata' => $row->code, 'name' => $row->name, 'active' => $row->enabled]
|
||||
);
|
||||
|
||||
$this->addMapping('airlines', $row->id, $airline->id);
|
||||
$this->addMapping('airlines', $row->code, $airline->id);
|
||||
|
||||
if ($airline->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' airlines');
|
||||
}
|
||||
|
||||
/**
|
||||
* Imported the aircraft
|
||||
*/
|
||||
protected function importAircraft()
|
||||
{
|
||||
$this->comment('--- AIRCRAFT IMPORT ---');
|
||||
|
||||
$subfleet = $this->getSubfleet();
|
||||
|
||||
$this->info('Subfleet ID is '.$subfleet->id);
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('aircraft') as $row) {
|
||||
$aircraft = Aircraft::firstOrCreate(
|
||||
['name' => $row->fullname, 'registration' => $row->registration],
|
||||
['icao' => $row->icao,
|
||||
'subfleet_id' => $subfleet->id,
|
||||
'active' => $row->enabled,
|
||||
]);
|
||||
|
||||
$this->addMapping('aircraft', $row->id, $aircraft->id);
|
||||
|
||||
if ($aircraft->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' aircraft');
|
||||
}
|
||||
|
||||
/**
|
||||
* Import all of the airports
|
||||
*/
|
||||
protected function importAirports()
|
||||
{
|
||||
$this->comment('--- AIRPORT IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('airports') as $row) {
|
||||
$attrs = [
|
||||
'id' => trim($row->icao),
|
||||
'icao' => trim($row->icao),
|
||||
'name' => $row->name,
|
||||
'country' => $row->country,
|
||||
'lat' => $row->lat,
|
||||
'lon' => $row->lng,
|
||||
'hub' => $row->hub,
|
||||
];
|
||||
|
||||
$airport = Airport::updateOrCreate(
|
||||
['id' => $attrs['id']],
|
||||
$attrs
|
||||
);
|
||||
|
||||
if ($airport->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' airports');
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the flights and schedules
|
||||
*/
|
||||
protected function importFlights()
|
||||
{
|
||||
$this->comment('--- FLIGHT SCHEDULE IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('schedules') as $row) {
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
|
||||
$flight_num = trim($row->flightnum);
|
||||
|
||||
$attrs = [
|
||||
'dpt_airport_id' => $row->depicao,
|
||||
'arr_airport_id' => $row->arricao,
|
||||
'route' => $row->route ?: '',
|
||||
'distance' => round($row->distance ?: 0, 2),
|
||||
'level' => $row->flightlevel ?: 0,
|
||||
'dpt_time' => $row->deptime ?: '',
|
||||
'arr_time' => $row->arrtime ?: '',
|
||||
'flight_time' => $this->convertDuration($row->flighttime) ?: '',
|
||||
'notes' => $row->notes ?: '',
|
||||
'active' => $row->enabled ?: true,
|
||||
];
|
||||
|
||||
try {
|
||||
$flight = Flight::updateOrCreate(
|
||||
['airline_id' => $airline_id, 'flight_number' => $flight_num],
|
||||
$attrs
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
//$this->error($e);
|
||||
}
|
||||
|
||||
$this->addMapping('flights', $row->id, $flight->id);
|
||||
|
||||
// TODO: deserialize route_details into ACARS table
|
||||
|
||||
if ($flight->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' flights');
|
||||
}
|
||||
|
||||
/**
|
||||
* Import all of the PIREPs
|
||||
*/
|
||||
protected function importPireps()
|
||||
{
|
||||
$this->comment('--- PIREP IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('pireps') as $row) {
|
||||
$pirep_id = $row->pirepid;
|
||||
$user_id = $this->getMapping('users', $row->pilotid);
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
$aircraft_id = $this->getMapping('aircraft', $row->aircraft);
|
||||
|
||||
$attrs = [
|
||||
//'id' => $pirep_id,
|
||||
'user_id' => $user_id,
|
||||
'airline_id' => $airline_id,
|
||||
'aircraft_id' => $aircraft_id,
|
||||
'flight_number' => $row->flightnum ?: '',
|
||||
'dpt_airport_id' => $row->depicao,
|
||||
'arr_airport_id' => $row->arricao,
|
||||
'block_fuel' => $row->fuelused,
|
||||
'route' => $row->route ?: '',
|
||||
'source_name' => $row->source,
|
||||
'created_at' => $this->parseDate($row->submitdate),
|
||||
'updated_at' => $this->parseDate($row->modifieddate),
|
||||
];
|
||||
|
||||
// Set the distance
|
||||
$distance = round($row->distance ?: 0, 2);
|
||||
$attrs['distance'] = $distance;
|
||||
$attrs['planned_distance'] = $distance;
|
||||
|
||||
// Set the flight time properly
|
||||
$duration = $this->convertDuration($row->flighttime_stamp);
|
||||
$attrs['flight_time'] = $duration;
|
||||
$attrs['planned_flight_time'] = $duration;
|
||||
|
||||
// Set how it was filed
|
||||
if (strtoupper($row->source) === 'MANUAL') {
|
||||
$attrs['source'] = PirepSource::MANUAL;
|
||||
} else {
|
||||
$attrs['source'] = PirepSource::ACARS;
|
||||
}
|
||||
|
||||
// Set the flight type
|
||||
$row->flighttype = strtoupper($row->flighttype);
|
||||
if ($row->flighttype === 'P') {
|
||||
$attrs['flight_type'] = FlightType::SCHED_PAX;
|
||||
} elseif ($row->flighttype === 'C') {
|
||||
$attrs['flight_type'] = FlightType::SCHED_CARGO;
|
||||
} else {
|
||||
$attrs['flight_type'] = FlightType::CHARTER_PAX_ONLY;
|
||||
}
|
||||
|
||||
// Set the flight level of the PIREP is set
|
||||
if (property_exists($row, 'flightlevel')) {
|
||||
$attrs['level'] = $row->flightlevel;
|
||||
} else {
|
||||
$attrs['level'] = 0;
|
||||
}
|
||||
|
||||
$pirep = Pirep::updateOrCreate(
|
||||
['id' => $pirep_id],
|
||||
$attrs
|
||||
);
|
||||
|
||||
$source = strtoupper($row->source);
|
||||
if ($source === 'SMARTCARS') {
|
||||
// TODO: Parse smartcars log into the acars table
|
||||
} elseif ($source === 'KACARS') {
|
||||
// TODO: Parse kACARS log into acars table
|
||||
} elseif ($source === 'XACARS') {
|
||||
// TODO: Parse XACARS log into acars table
|
||||
}
|
||||
|
||||
// TODO: Add extra fields in as PIREP fields
|
||||
$this->addMapping('pireps', $row->pirepid, $pirep->id);
|
||||
|
||||
if ($pirep->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' pireps');
|
||||
}
|
||||
|
||||
protected function importUsers()
|
||||
{
|
||||
$this->comment('--- USER IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('pilots', 50) as $row) {
|
||||
// TODO: What to do about pilot ids
|
||||
|
||||
$name = $row->firstname.' '.$row->lastname;
|
||||
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
$rank_id = $this->getMapping('ranks', $row->rank);
|
||||
$state = $this->getUserState($row->retired);
|
||||
|
||||
$new_password = Str::random(60);
|
||||
|
||||
$attrs = [
|
||||
'name' => $name,
|
||||
'password' => Hash::make($new_password),
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $airline_id,
|
||||
'rank_id' => $rank_id,
|
||||
'home_airport_id' => $row->hub,
|
||||
'curr_airport_id' => $row->hub,
|
||||
'flights' => (int) $row->totalflights,
|
||||
'flight_time' => Utils::hoursToMinutes($row->totalhours),
|
||||
'state' => $state,
|
||||
'created_at' => $this->parseDate($row->joindate),
|
||||
];
|
||||
|
||||
$user = User::updateOrCreate(
|
||||
['email' => $row->email],
|
||||
$attrs
|
||||
);
|
||||
|
||||
$this->addMapping('users', $row->pilotid, $user->id);
|
||||
|
||||
if ($user->wasRecentlyCreated) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '.$count.' users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through and set the last PIREP ID for the users
|
||||
*/
|
||||
protected function findLastPireps()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate all of the user ranks
|
||||
*/
|
||||
protected function recalculateRanks()
|
||||
{
|
||||
/*$this->comment('--- RECALCULATING RANKS ---');*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's new state from their original state
|
||||
*
|
||||
* @param $state
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getUserState($state)
|
||||
{
|
||||
// TODO: This state might differ between simpilot and classic version
|
||||
|
||||
$state = (int) $state;
|
||||
|
||||
// Declare array of classic states
|
||||
$phpvms_classic_states = [
|
||||
'ACTIVE' => 0,
|
||||
'INACTIVE' => 1,
|
||||
'BANNED' => 2,
|
||||
'ON_LEAVE' => 3,
|
||||
];
|
||||
|
||||
// Decide which state they will be in accordance with v7
|
||||
if ($state === $phpvms_classic_states['ACTIVE']) {
|
||||
return UserState::ACTIVE;
|
||||
} elseif ($state === $phpvms_classic_states['INACTIVE']) {
|
||||
// TODO: Make an inactive state?
|
||||
return UserState::REJECTED;
|
||||
} elseif ($state === $phpvms_classic_states['BANNED']) {
|
||||
return UserState::SUSPENDED;
|
||||
} elseif ($state === $phpvms_classic_states['ON_LEAVE']) {
|
||||
return UserState::ON_LEAVE;
|
||||
}
|
||||
$this->error('Unknown status: '.$state);
|
||||
}
|
||||
}
|
||||
27
app/Contracts/AirportLookup.php
Normal file
27
app/Contracts/AirportLookup.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Models\Airport;
|
||||
|
||||
abstract class AirportLookup
|
||||
{
|
||||
/**
|
||||
* Lookup the information for an airport. Needs to return an instance of the
|
||||
* Airport model, or an array with the properties listed in the Airport model.
|
||||
*
|
||||
* The in-use implementation can be changed in the config/phpvms.php file, so
|
||||
* different services can be used, in-case vaCentral one isn't working or there
|
||||
* is a better one available. Don't handle any caching in this layer, that happens
|
||||
* at the service layer
|
||||
*
|
||||
* Return null if there's an error or nothing was found
|
||||
*
|
||||
* @example App\Services\AirportLookup\VaCentralLookup
|
||||
*
|
||||
* @param string $icao
|
||||
*
|
||||
* @return Airport|null
|
||||
*/
|
||||
abstract public function getAirport($icao);
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Facades\Utils;
|
||||
use App\Models\Award as AwardModel;
|
||||
use App\Models\User;
|
||||
use App\Models\UserAward;
|
||||
use Log;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Base class for the Awards, you need to extend this, and implement:
|
||||
@@ -38,12 +39,6 @@ abstract class Award
|
||||
protected $award;
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* AwardInterface constructor.
|
||||
*
|
||||
* @param AwardModel $award
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(AwardModel $award = null, User $user = null)
|
||||
{
|
||||
$this->award = $award;
|
||||
@@ -73,7 +68,7 @@ abstract class Award
|
||||
*
|
||||
* @return bool|UserAward
|
||||
*/
|
||||
final protected function addAward()
|
||||
protected function addAward()
|
||||
{
|
||||
$w = [
|
||||
'user_id' => $this->user->id,
|
||||
@@ -90,7 +85,7 @@ abstract class Award
|
||||
|
||||
try {
|
||||
$award->save();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
Log::error(
|
||||
'Error saving award: '.$e->getMessage(),
|
||||
$e->getTrace()
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
namespace App\Contracts;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
@@ -16,15 +16,25 @@ abstract class Command extends \Illuminate\Console\Command
|
||||
abstract public function handle();
|
||||
|
||||
/**
|
||||
* Splice the logger and replace the active handlers with
|
||||
* the handlers from the "cron" stack in config/logging.php
|
||||
*
|
||||
* Close out any of the existing handlers so we don't leave
|
||||
* file descriptors leaking around
|
||||
*
|
||||
* @param string $channel_name Channel name to grab the handlers from
|
||||
* Adjust the logging depending on where we're running from
|
||||
*/
|
||||
public function redirectLoggingToStdout($channel_name): void
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Running in the console but not in the tests
|
||||
if (app()->runningInConsole() && env('APP_ENV') !== 'testing') {
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splice the logger and replace the active handlers with the handlers from the
|
||||
* a stack in config/logging.php
|
||||
*
|
||||
* @param string $channel_name Channel name from config/logging.php
|
||||
*/
|
||||
public function redirectLoggingToFile($channel_name): void
|
||||
{
|
||||
$logger = app(\Illuminate\Log\Logger::class);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
@@ -12,7 +12,9 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
abstract class Controller extends \Illuminate\Routing\Controller
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
|
||||
/**
|
||||
* Write a error to the flash and redirect the user to a route
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Borrowed some ideas from myclabs/php-enum after this was created
|
||||
@@ -1,14 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Class FormRequest
|
||||
*/
|
||||
class FormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
{
|
||||
protected $sanitizer;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Models\Airline;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
22
app/Contracts/Listener.php
Normal file
22
app/Contracts/Listener.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
abstract class Listener
|
||||
{
|
||||
public static $callbacks = [];
|
||||
|
||||
/**
|
||||
* Sets up any callbacks that are defined in the child class
|
||||
*
|
||||
* @param $events
|
||||
*/
|
||||
public function subscribe(Dispatcher $events): void
|
||||
{
|
||||
foreach (static::$callbacks as $klass => $cb) {
|
||||
$events->listen($klass, get_class($this).'@'.$cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
app/Contracts/Metar.php
Normal file
55
app/Contracts/Metar.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Base class for implementing retrieving METARs
|
||||
*/
|
||||
abstract class Metar
|
||||
{
|
||||
/**
|
||||
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
||||
* since this shouldn't be directly called. Call `get_metar($icao)` instead
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function metar($icao): string;
|
||||
|
||||
/**
|
||||
* Download the METAR, wrap in caching
|
||||
*
|
||||
* @param $icao
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metar($icao): string
|
||||
{
|
||||
$cache = config('cache.keys.WEATHER_LOOKUP');
|
||||
$key = $cache['key'].$icao;
|
||||
|
||||
if (Cache::has($key)) {
|
||||
$raw_metar = Cache::get($key);
|
||||
if ($raw_metar !== '') {
|
||||
return $raw_metar;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$raw_metar = $this->metar($icao);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($raw_metar !== '') {
|
||||
Cache::put($key, $raw_metar, $cache['time']);
|
||||
}
|
||||
|
||||
return $raw_metar;
|
||||
}
|
||||
}
|
||||
11
app/Contracts/Middleware.php
Normal file
11
app/Contracts/Middleware.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
interface Middleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Support\Database;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class Migration
|
||||
@@ -23,6 +25,22 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed a YAML file into the database
|
||||
*
|
||||
* @param string $file Full path to yml file to seed
|
||||
*/
|
||||
public function seedFile($file): void
|
||||
{
|
||||
try {
|
||||
$path = base_path($file);
|
||||
Database::seed_from_yaml_file($path, false);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Unable to load '.$file.' file');
|
||||
Log::error($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add rows to a table
|
||||
*
|
||||
@@ -1,21 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Class Model
|
||||
*
|
||||
* @property mixed $id
|
||||
* @property bool $skip_mutator
|
||||
*
|
||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
abstract class Model extends \Illuminate\Database\Eloquent\Model
|
||||
{
|
||||
/**
|
||||
* Max length of ID for string columns
|
||||
*/
|
||||
public const ID_MAX_LENGTH = 12;
|
||||
|
||||
/**
|
||||
* For the factories, skip the mutators. Only apply to one instance
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $skip_mutator = false;
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
|
||||
/**
|
||||
* Class Repository
|
||||
*/
|
||||
abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
|
||||
abstract class Repository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @param $id
|
||||
@@ -108,4 +106,32 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
|
||||
return $q;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository, paginated. Added in extra parameter to read from the
|
||||
* request which page it should be on
|
||||
*
|
||||
* @param null $limit
|
||||
* @param array $columns
|
||||
* @param string $method
|
||||
*
|
||||
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function paginate($limit = null, $columns = ['*'], $method = 'paginate')
|
||||
{
|
||||
$this->applyCriteria();
|
||||
$this->applyScope();
|
||||
|
||||
$max = config('repository.pagination.limit', 50);
|
||||
$limit = (int) ($limit ?? request()->query('limit') ?? $max);
|
||||
$page = (int) request()->query('page', 1);
|
||||
|
||||
$results = $this->model->{$method}($limit, $columns, 'page', $page);
|
||||
$results->appends(app('request')->query());
|
||||
$this->resetModel();
|
||||
|
||||
return $this->parserResult($results);
|
||||
}
|
||||
}
|
||||
24
app/Contracts/RouteFinder.php
Normal file
24
app/Contracts/RouteFinder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Abstract class for finding a route from a departure airport to an arrival airport
|
||||
* Can allow for multiple, configurable methods for finding a route, whether it reaches
|
||||
* out to a REST API or implement some sort of internal logic to look through a file
|
||||
* or whatever the logic might be.
|
||||
*
|
||||
* Just one public-facing method needs to be implemented
|
||||
*/
|
||||
abstract class RouteFinder
|
||||
{
|
||||
/**
|
||||
* Find a route from the departure ICAO to the arrival ICAO
|
||||
*
|
||||
* @param $dptIcao
|
||||
* @param $arrIcao
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function findRoute($dptIcao, $arrIcao): string;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Class Service
|
||||
129
app/Contracts/Unit.php
Normal file
129
app/Contracts/Unit.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use ArrayAccess;
|
||||
use PhpUnitsOfMeasure\Exception\UnknownUnitOfMeasure;
|
||||
|
||||
/**
|
||||
* Abstract unit wrapper
|
||||
*/
|
||||
class Unit implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* The unit this is kept as
|
||||
*/
|
||||
public $unit;
|
||||
|
||||
/**
|
||||
* All of the units of this class
|
||||
*/
|
||||
public $units;
|
||||
|
||||
/**
|
||||
* Holds an instance of the PhpUnit type
|
||||
*
|
||||
* @var \PhpUnitsOfMeasure\AbstractPhysicalQuantity
|
||||
*/
|
||||
protected $instance;
|
||||
|
||||
/**
|
||||
* Units that are included as part of the REST response
|
||||
*/
|
||||
public $responseUnits = [];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function value()
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Just call toUnit() on the PhpUnitOfMeasure instance
|
||||
*
|
||||
* @param string $unit
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toUnit($unit)
|
||||
{
|
||||
return $this->instance->toUnit($unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the units that get sent back in a response
|
||||
*/
|
||||
public function getResponseUnits(): array
|
||||
{
|
||||
$response = [];
|
||||
foreach ($this->responseUnits as $unit) {
|
||||
$response[$unit] = $this[$unit];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements ArrayAccess
|
||||
*
|
||||
* @param $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->offsetGet($offset) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements ArrayAccess
|
||||
*
|
||||
* @param $offset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
try {
|
||||
$value = $this->instance->toUnit($offset);
|
||||
if (!$value) {
|
||||
return;
|
||||
}
|
||||
} catch (UnknownUnitOfMeasure $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
return round($value, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements ArrayAccess
|
||||
*
|
||||
* @param $offset
|
||||
* @param $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
// $this->units[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements ArrayAccess
|
||||
*
|
||||
* @param $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
// $this->units[$offset] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->offsetGet($this->unit);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
namespace App\Contracts;
|
||||
|
||||
use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Hourly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronHourly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Bid;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Cron\Hourly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronHourly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Pirep;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -13,7 +14,7 @@ use Carbon\Carbon;
|
||||
class RemoveExpiredLiveFlights extends Listener
|
||||
{
|
||||
/**
|
||||
* Remove expired live flights
|
||||
* Remove expired live flights that haven't had an update in the live time
|
||||
*
|
||||
* @param CronHourly $event
|
||||
*
|
||||
@@ -26,7 +27,7 @@ class RemoveExpiredLiveFlights extends Listener
|
||||
}
|
||||
|
||||
$date = Carbon::now()->subHours(setting('acars.live_time'));
|
||||
Pirep::whereDate('created_at', '<', $date)
|
||||
Pirep::whereDate('updated_at', '<', $date)
|
||||
->where('state', PirepState::IN_PROGRESS)
|
||||
->delete();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Monthly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronMonthly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\ExpenseType;
|
||||
use App\Services\Finance\RecurringFinanceService;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\ExpenseType;
|
||||
use App\Services\Finance\RecurringFinanceService;
|
||||
|
||||
|
||||
33
app/Cron/Nightly/NewVersionCheck.php
Normal file
33
app/Cron/Nightly/NewVersionCheck.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Services\VersionService;
|
||||
|
||||
/**
|
||||
* Determine if any pilots should be set to ON LEAVE status
|
||||
*/
|
||||
class NewVersionCheck extends Listener
|
||||
{
|
||||
private $versionSvc;
|
||||
|
||||
/**
|
||||
* @param VersionService $versionSvc
|
||||
*/
|
||||
public function __construct(VersionService $versionSvc)
|
||||
{
|
||||
$this->versionSvc = $versionSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set any users to being on leave after X days
|
||||
*
|
||||
* @param CronNightly $event
|
||||
*/
|
||||
public function handle(CronNightly $event): void
|
||||
{
|
||||
$this->versionSvc->isNewVersionAvailable();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Services\UserService;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Journal;
|
||||
use App\Repositories\JournalRepository;
|
||||
use Log;
|
||||
|
||||
@@ -2,24 +2,20 @@
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* This recalculates the balances on all of the journals
|
||||
*/
|
||||
class RecalculateStats extends Listener
|
||||
{
|
||||
private $userRepo;
|
||||
private $userSvc;
|
||||
|
||||
public function __construct(UserRepository $userRepo, UserService $userService)
|
||||
public function __construct(UserService $userService)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
$this->userSvc = $userService;
|
||||
}
|
||||
|
||||
@@ -35,14 +31,7 @@ class RecalculateStats extends Listener
|
||||
{
|
||||
Log::info('Recalculating balances');
|
||||
|
||||
$w = [
|
||||
['state', '!=', UserState::REJECTED],
|
||||
];
|
||||
|
||||
$users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']);
|
||||
foreach ($users as $user) {
|
||||
$this->userSvc->recalculateStats($user);
|
||||
}
|
||||
$this->userSvc->recalculateAllUserStats();
|
||||
|
||||
Log::info('Done recalculating stats');
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Cron\Nightly;
|
||||
|
||||
use App\Contracts\Listener;
|
||||
use App\Events\CronNightly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Enums\Days;
|
||||
use App\Models\Flight;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -8,7 +8,7 @@ use Faker\Generator as Faker;
|
||||
if (!function_exists('createFactoryICAO')) {
|
||||
function createFactoryICAO(): string
|
||||
{
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$max = strlen($characters) - 1;
|
||||
$string = '';
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
@@ -26,14 +26,15 @@ if (!function_exists('createFactoryICAO')) {
|
||||
* Add any number of airports. Don't really care if they're real or not
|
||||
*/
|
||||
$factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||
$used = [];
|
||||
return [
|
||||
'id' => function () use ($used) {
|
||||
do {
|
||||
$string = createFactoryICAO();
|
||||
} while (in_array($string, $used, true));
|
||||
$usedIcaos = [];
|
||||
|
||||
return $string;
|
||||
return [
|
||||
'id' => function () use ($usedIcaos) {
|
||||
do {
|
||||
$airport = createFactoryICAO();
|
||||
} while (in_array($airport, $usedIcaos, true));
|
||||
|
||||
return $airport;
|
||||
},
|
||||
'icao' => function (array $apt) {
|
||||
return $apt['id'];
|
||||
@@ -48,8 +49,8 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||
'lon' => $faker->longitude,
|
||||
'hub' => false,
|
||||
'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 1, 10),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 1, 10),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 1, 10),
|
||||
];
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
|
||||
'alt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'distance' => $faker->numberBetween(0, 3000),
|
||||
'distance' => $faker->numberBetween(1, 1000),
|
||||
'route' => null,
|
||||
'level' => 0,
|
||||
'dpt_time' => $faker->time(),
|
||||
@@ -35,7 +35,7 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
|
||||
'start_date' => null,
|
||||
'end_date' => null,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $flight) {
|
||||
'updated_at' => static function (array $flight) {
|
||||
return $flight['created_at'];
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use Carbon\Carbon;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
@@ -7,10 +10,15 @@ use Faker\Generator as Faker;
|
||||
* Create a new PIREP
|
||||
*/
|
||||
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
$airline = factory(App\Models\Airline::class)->create();
|
||||
$flight = factory(App\Models\Flight::class)->create([
|
||||
'airline_id' => $airline->id,
|
||||
]);
|
||||
|
||||
return [
|
||||
'id' => $faker->unique()->numberBetween(10, 10000000),
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
'airline_id' => function () use ($airline) {
|
||||
return $airline->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
@@ -18,18 +26,19 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
'aircraft_id' => function () {
|
||||
return factory(App\Models\Aircraft::class)->create()->id;
|
||||
},
|
||||
'flight_number' => function (array $pirep) {
|
||||
return factory(App\Models\Flight::class)->create([
|
||||
'airline_id' => $pirep['airline_id'],
|
||||
])->flight_number;
|
||||
'flight_id' => function () use ($flight) {
|
||||
return $flight->id;
|
||||
},
|
||||
'flight_number' => function () use ($flight) {
|
||||
return $flight->flight_number;
|
||||
},
|
||||
'route_code' => null,
|
||||
'route_leg' => null,
|
||||
'dpt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
'dpt_airport_id' => function () use ($flight) {
|
||||
return $flight->dpt_airport_id;
|
||||
},
|
||||
'arr_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
'arr_airport_id' => function () use ($flight) {
|
||||
return $flight->arr_airport_id;
|
||||
},
|
||||
'level' => $faker->numberBetween(20, 400),
|
||||
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||
@@ -37,16 +46,18 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'planned_flight_time' => $faker->numberBetween(60, 360),
|
||||
'zfw' => $faker->randomFloat(2),
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 30000),
|
||||
'fuel_used' => $faker->randomFloat(2, 0, 30000),
|
||||
'block_on_time' => Carbon::now('UTC'),
|
||||
'block_off_time' => function (array $pirep) {
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 1000),
|
||||
'fuel_used' => function (array $pirep) {
|
||||
return round($pirep['block_fuel'] * .9, 2); // 90% of the fuel loaded was used
|
||||
},
|
||||
'block_on_time' => Carbon::now('UTC'),
|
||||
'block_off_time' => function (array $pirep) {
|
||||
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
|
||||
},
|
||||
'route' => $faker->text(200),
|
||||
'notes' => $faker->text(200),
|
||||
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
||||
'source_name' => 'Test Factory',
|
||||
'source_name' => 'TestFactory',
|
||||
'state' => PirepState::PENDING,
|
||||
'status' => PirepStatus::SCHEDULED,
|
||||
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
|
||||
|
||||
@@ -8,6 +8,7 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'id' => null,
|
||||
'pilot_id' => 0,
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => $password ?: $password = Hash::make('secret'),
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use App\Services\Installer\SeederService;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
{
|
||||
private $migrationSvc;
|
||||
private $seederSvc;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->migrationSvc = new \Modules\Installer\Services\MigrationService();
|
||||
$this->seederSvc = app(SeederService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ class CreateSettingsTable extends Migration
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$this->migrationSvc->updateAllSettings();
|
||||
$this->seederSvc->syncAllSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class RolesPermissionsTables extends Migration
|
||||
@@ -74,11 +74,6 @@ class RolesPermissionsTables extends Migration
|
||||
'name' => 'admin',
|
||||
'display_name' => 'Administrators',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'user',
|
||||
'display_name' => 'Pilot',
|
||||
],
|
||||
];
|
||||
|
||||
$this->addData('roles', $roles);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAirlinesTable extends Migration
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use App\Models\Enums\AircraftState;
|
||||
use App\Models\Enums\AircraftStatus;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFaresTable extends Migration
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAirportsTable extends Migration
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use App\Contracts\Model;
|
||||
use App\Models\Enums\FlightType;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
@@ -14,7 +15,7 @@ class CreateFlightTables extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('flights', function (Blueprint $table) {
|
||||
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('id', Model::ID_MAX_LENGTH);
|
||||
$table->unsignedInteger('airline_id');
|
||||
$table->unsignedInteger('flight_number');
|
||||
$table->string('route_code', 5)->nullable();
|
||||
@@ -47,7 +48,7 @@ class CreateFlightTables extends Migration
|
||||
});
|
||||
|
||||
Schema::create('flight_fare', function (Blueprint $table) {
|
||||
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('flight_id', Model::ID_MAX_LENGTH);
|
||||
$table->unsignedInteger('fare_id');
|
||||
$table->string('price', 10)->nullable();
|
||||
$table->string('cost', 10)->nullable();
|
||||
@@ -71,7 +72,7 @@ class CreateFlightTables extends Migration
|
||||
*/
|
||||
Schema::create('flight_field_values', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('flight_id', Model::ID_MAX_LENGTH);
|
||||
$table->string('name', 50);
|
||||
$table->string('slug', 50)->nullable();
|
||||
$table->text('value');
|
||||
@@ -83,7 +84,7 @@ class CreateFlightTables extends Migration
|
||||
Schema::create('flight_subfleet', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('flight_id', Model::ID_MAX_LENGTH);
|
||||
|
||||
$table->index(['subfleet_id', 'flight_id']);
|
||||
$table->index(['flight_id', 'subfleet_id']);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateRanksTable extends Migration
|
||||
@@ -28,21 +28,6 @@ class CreateRanksTable extends Migration
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
/**
|
||||
* Initial required data...
|
||||
*/
|
||||
$ranks = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'New Pilot',
|
||||
'hours' => 0,
|
||||
'acars_base_pay_rate' => 50,
|
||||
'manual_base_pay_rate' => 25,
|
||||
],
|
||||
];
|
||||
|
||||
$this->addData('ranks', $ranks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use App\Contracts\Model;
|
||||
use App\Models\Enums\FlightType;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
@@ -16,7 +17,7 @@ class CreatePirepTables extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('pireps', function (Blueprint $table) {
|
||||
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('id', Model::ID_MAX_LENGTH);
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->unsignedInteger('airline_id');
|
||||
$table->unsignedInteger('aircraft_id')->nullable();
|
||||
@@ -57,7 +58,7 @@ class CreatePirepTables extends Migration
|
||||
|
||||
Schema::create('pirep_comments', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('pirep_id', Model::ID_MAX_LENGTH);
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->text('comment');
|
||||
$table->timestamps();
|
||||
@@ -65,7 +66,7 @@ class CreatePirepTables extends Migration
|
||||
|
||||
Schema::create('pirep_fares', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('pirep_id', Model::ID_MAX_LENGTH);
|
||||
$table->unsignedInteger('fare_id');
|
||||
$table->unsignedInteger('count')->nullable()->default(0);
|
||||
|
||||
@@ -81,7 +82,7 @@ class CreatePirepTables extends Migration
|
||||
|
||||
Schema::create('pirep_field_values', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('pirep_id', Model::ID_MAX_LENGTH);
|
||||
$table->string('name', 50);
|
||||
$table->string('slug', 50)->nullable();
|
||||
$table->string('value')->nullable();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use App\Contracts\Model;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -16,7 +17,7 @@ class CreateBidsTable extends Migration
|
||||
Schema::create('bids', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('flight_id', Model::ID_MAX_LENGTH);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('user_id');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateAcarsTables extends Migration
|
||||
{
|
||||
Schema::create('acars', function (Blueprint $table) {
|
||||
$table->string('id', 12);
|
||||
$table->string('pirep_id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('pirep_id', \App\Contracts\Model::ID_MAX_LENGTH);
|
||||
$table->unsignedTinyInteger('type');
|
||||
$table->unsignedInteger('nav_type')->nullable();
|
||||
$table->unsignedInteger('order')->default(0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateStatsTable extends Migration
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -14,7 +14,7 @@ class CreateFilesTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->string('id', \App\Interfaces\Model::ID_MAX_LENGTH);
|
||||
$table->string('id', \App\Contracts\Model::ID_MAX_LENGTH);
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('disk')->nullable();
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddReadonlyToRoles extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('roles', static function (Blueprint $table) {
|
||||
$table->boolean('read_only')->default(false);
|
||||
});
|
||||
|
||||
// Set the two main roles as read-only
|
||||
DB::table('roles')
|
||||
->whereIn('name', ['admin', 'user'])
|
||||
->update(['read_only' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('roles', static function (Blueprint $table) {
|
||||
$table->dropColumn('read_only');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UsersAddPilotId extends Migration
|
||||
{
|
||||
/**
|
||||
* Kinda of gross operations to change the pilot ID column
|
||||
* 1. Add an `pilot_id` column, which will get populated with the current ID
|
||||
* 2. Drop the `id` column, and then recreate it as a string field
|
||||
* 3. Iterate through all of the users and set their `id` to the `pilot_id`
|
||||
* 4. Change the other tables column types that reference `user_id`
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('pilot_id')
|
||||
->after('id')
|
||||
->unique()
|
||||
->nullable()
|
||||
->index('users_pilot_id');
|
||||
});
|
||||
|
||||
// Migrate the current pilot IDs
|
||||
DB::update('UPDATE `users` SET `pilot_id`=`id`');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('pilot_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user