diff --git a/.travis/Formatting.xml b/.github/scripts/Formatting.xml similarity index 100% rename from .travis/Formatting.xml rename to .github/scripts/Formatting.xml diff --git a/.travis/deploy_script.sh b/.github/scripts/build.sh old mode 100755 new mode 100644 similarity index 50% rename from .travis/deploy_script.sh rename to .github/scripts/build.sh index 96fb20b2..9f9b7f42 --- a/.travis/deploy_script.sh +++ b/.github/scripts/build.sh @@ -1,52 +1,12 @@ #!/usr/bin/env bash -if [ "$TRAVIS" != "true" ]; then - exit 0 -fi - -cd $TRAVIS_BUILD_DIR - -if test "$TRAVIS_TAG"; then - VERSION=$TRAVIS_TAG - - # Pass in the tag as the version to write out - php artisan phpvms:version --write --write-full-version "${VERSION}" - FULL_VERSION=$(php artisan phpvms:version) -else - echo "On branch $TRAVIS_BRANCH" - - if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then - echo "Not on valid branch, exiting" - exit 0 - fi - - # Write the version out but place the branch ID in there - # This is only for the dev branch - BASE_VERSION=$(php artisan phpvms:version --base-only) - - # This now includes the pre-release version, so "-dev" by default - VERSION=${BASE_VERSION} - - # Don't pass in a version here, just write out the latest hash - php artisan phpvms:version --write "${VERSION}" - FULL_VERSION=$(php artisan phpvms:version) -fi - -FILE_NAME="phpvms-${VERSION}" -TAR_NAME="$FILE_NAME.tar.gz" -ZIP_NAME="$FILE_NAME.zip" - echo "Version: ${VERSION}" echo "Full Version: ${FULL_VERSION}" echo "Package name: ${TAR_NAME}" - -echo "===========================" +echo "Current directory: ${BASE_DIR}" echo "Cleaning files" -rm -rf vendor -composer install --no-dev --prefer-dist --no-interaction --verbose - # Leftover individual files to delete declare -a remove_files=( .git @@ -107,44 +67,20 @@ mkdir -p storage/framework/cache mkdir -p storage/framework/sessions mkdir -p storage/framework/views -# Regenerate the autoloader and classes -composer dump-autoload -make clean - cd /tmp -ls -al $TRAVIS_BUILD_DIR/../ -tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR . +ls -al $BASE_DIR/../ + +tar -czf $TAR_NAME -C $BASE_DIR . sha256sum $TAR_NAME >"$TAR_NAME.sha256" tar2zip $TAR_NAME sha256sum $ZIP_NAME >"$ZIP_NAME.sha256" ls -al /tmp -echo "Uploading to S3" -mkdir -p $TRAVIS_BUILD_DIR/build -cd $TRAVIS_BUILD_DIR/build +echo "Moving to dist" +mkdir -p $BASE_DIR/dist +cd $BASE_DIR/dist mv "/tmp/$TAR_NAME" "/tmp/$ZIP_NAME" "/tmp/$TAR_NAME.sha256" "/tmp/$ZIP_NAME.sha256" . -artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256 $ZIP_NAME.sha256 -# Upload the version for a tagged release. Move to a version file in different -# tags. Within phpVMS, we have an option of which version to track in the admin -if test "$TRAVIS_TAG"; then - echo "Uploading release version file" - cp "$TRAVIS_BUILD_DIR/VERSION" release_version - artifacts upload --target-paths "/" release_version -else - echo "Uploading ${TRAVIS_BRANCH}_version file" - cp $TRAVIS_BUILD_DIR/VERSION ${TRAVIS_BRANCH}_version - artifacts upload --target-paths "/" ${TRAVIS_BRANCH}_version -fi - -#if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_BRANCH" != "dev" ]; then -# echo "Skipping Discord branch update broadcast" -#else - curl -X POST \ - --data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME (${FULL_VERSION})\"}" \ - -H "Content-Type: application/json" \ - $DISCORD_WEBHOOK_URL -#fi diff --git a/.travis/env.travis.php b/.github/scripts/env.php similarity index 100% rename from .travis/env.travis.php rename to .github/scripts/env.php diff --git a/.travis/my.cnf b/.github/scripts/my.cnf similarity index 100% rename from .travis/my.cnf rename to .github/scripts/my.cnf diff --git a/.travis/phpunit.travis.xml b/.github/scripts/phpunit.xml similarity index 100% rename from .travis/phpunit.travis.xml rename to .github/scripts/phpunit.xml diff --git a/.github/scripts/version.sh b/.github/scripts/version.sh new file mode 100644 index 00000000..b877103a --- /dev/null +++ b/.github/scripts/version.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +if test "$GIT_TAG_NAME"; then + export VERSION=$GIT_TAG_NAME + + # Pass in the tag as the version to write out + php artisan phpvms:version --write --write-full-version "${VERSION}" + export FULL_VERSION=$(php artisan phpvms:version) +else + export BRANCH=${GITHUB_REF##*/} + echo "On branch $BRANCH" + + # Write the version out but place the branch ID in there + # This is only for the dev branch + export BASE_VERSION=$(php artisan phpvms:version --base-only) + + # This now includes the pre-release version, so "-dev" by default + export VERSION=${BASE_VERSION} + + # Don't pass in a version here, just write out the latest hash + php artisan phpvms:version --write "${VERSION}" + export FULL_VERSION=$(php artisan phpvms:version) +fi + +export FILE_NAME="phpvms-${VERSION}" +export TAR_NAME="$FILE_NAME.tar.gz" +export ZIP_NAME="$FILE_NAME.zip" +export BASE_DIR=`pwd` + +# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files +echo "BRANCH=${BRANCH}" >> $GITHUB_ENV +echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV +echo "TAR_NAME=${TAR_NAME}" >> $GITHUB_ENV +echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV +echo "BASE_DIR=${BASE_DIR}" >> $GITHUB_ENV +echo "DISCORD_MSG=A new build is available at http://downloads.phpvms.net/$TAR_NAME (${FULL_VERSION})" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..96f0503c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,252 @@ +name: 'Build' +on: ['push', 'pull_request', 'workflow_dispatch', 'release'] +jobs: + build: + runs-on: ubuntu-18.04 + if: github.repository == 'nabeelio/phpvms' + strategy: + fail-fast: true + matrix: + php-versions: ['7.3', '7.4'] + name: PHP ${{ matrix.php-versions }} + env: + extensions: intl, pcov, mbstring + key: cache-v1 + steps: + - name: Checkout + uses: actions/checkout@v2 + + # Configure Caching + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v1 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # Configure PHP + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + ini-values: post_max_size=256M, short_open_tag=On + coverage: xdebug + tools: php-cs-fixer, phpunit + + - name: Shutdown Ubuntu MySQL + run: sudo service mysql stop + + - name: Install MariaDB + uses: getong/mariadb-action@v1.1 + with: + character set server: 'utf8' + collation server: 'utf8_general_ci' + mysql database: 'phpvms' + mysql root password: '' + mysql user: '' + mysql password: '' + + - name: Configure Environment + run: | + php --version + mysql --version + # Downgrade composer version to 1.x + composer self-update --1 + composer install --dev --no-interaction --verbose + cp .github/scripts/env.php env.php + cp .github/scripts/phpunit.xml phpunit.xml + php artisan database:create --reset + php artisan migrate:refresh --seed + + - name: Run Tests + run: | + vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no + vendor/bin/phpunit --debug --verbose + + # This runs after all of the tests, run have run. Creates a cleaned up version of the + # distro, and then creates the artifact to push up to S3 or wherever + artifacts: + name: 'Create dev build' + needs: build + runs-on: 'ubuntu-18.04' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - uses: olegtarasov/get-tag@v2.1 + id: tagName + + # Configure Caching + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # Dependencies + - name: 'Install Release Dependencies' + run: | + rm -rf vendor + sudo npm i tar-to-zip -g + composer self-update --1 + composer install --no-dev --prefer-dist --no-interaction --verbose + sudo chmod +x ./.github/scripts/* + + - name: Get version + run: .github/scripts/version.sh + + - name: Build Distro + run: .github/scripts/build.sh + + - name: Upload S3 + uses: shallwefootball/s3-upload-action@v1.1.3 + with: + aws_key_id: ${{ secrets.S3_BUILD_ARTIFACTS_ACCESS_KEY_ID }} + aws_secret_access_key: ${{ secrets.S3_BUILD_ARTIFACTS_SECRET_ACCESS_KEY}} + aws_bucket: ${{ secrets.S3_BUCKET_NAME }} + source_dir: 'dist' + destination_dir: '' + + - name: Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@0.3.0 + with: + # DISCORD_MSG is defined in versions.sh + args: '{{ DISCORD_MSG }}' + + # This runs after all of the tests, run have run. Creates a cleaned up version of the + # distro, and then creates the artifact to push up to S3 or wherever + # https://github.com/actions/create-release + release: + name: 'Create Release' + needs: build + runs-on: 'ubuntu-18.04' + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - uses: olegtarasov/get-tag@v2.1 + id: tagName + + # Configure Caching + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # Dependencies + - name: 'Install Release Dependencies' + run: | + rm -rf vendor + sudo npm i tar-to-zip -g + composer self-update --1 + composer install --no-dev --prefer-dist --no-interaction --verbose + sudo chmod +x ./.github/scripts/* + + - name: Get version + run: .github/scripts/version.sh + + - name: Build Distro + run: .github/scripts/build.sh + + - name: Upload S3 + uses: shallwefootball/s3-upload-action@v1.1.3 + with: + aws_key_id: ${{ secrets.S3_BUILD_ARTIFACTS_ACCESS_KEY_ID }} + aws_secret_access_key: ${{ secrets.S3_BUILD_ARTIFACTS_SECRET_ACCESS_KEY}} + aws_bucket: ${{ secrets.S3_BUCKET_NAME }} + source_dir: 'dist' + destination_dir: '' + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get version + run: .github/scripts/version.sh + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + # Upload the tar file to the release + - name: Upload Tar Asset + id: upload-tar-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/{{TAR_NAME}} + asset_name: '{{ TAR_NAME }}' + asset_content_type: application/gzip + + # upload the zip file to the release + - name: Upload Zip Asset + id: upload-zip-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/{{ZIP_NAME}} + asset_name: '{{ ZIP_NAME }}' + asset_content_type: application/zip + + - name: Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@0.3.0 + with: + # DISCORD_MSG is defined in versions.sh + args: '{{ DISCORD_MSG }}' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a88d8153..00000000 --- a/.travis.yml +++ /dev/null @@ -1,162 +0,0 @@ -# -# Travis CI config file -# - -language: php -php: - - '7.4' - - '7.3' - -#env: -# - DB=mysql -# - DB=mariadb - -cache: - # Cache lives for 10 min - # Default of 3m might not be long enough for all the runs - timeout: 600 - directories: - - "$HOME/.composer/cache" - - "$HOME/.npm" - -services: -- mysql - -#addons: -# mariadb: '10.2' - -install: - - php --version - - mysql --version - # Downgrade composer version to 1.x - - composer self-update --1 - - composer install --dev --no-interaction --verbose - - npm i tar-to-zip -g - - cp .travis/env.travis.php env.php - - cp .travis/phpunit.travis.xml phpunit.xml - -before_script: - - php artisan database:create --reset - - php artisan migrate:refresh --seed - -script: - - vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --diff --using-cache=no - - vendor/bin/phpunit --debug --verbose - -after_failure: - - cat storage/logs/*.log - -# Refer to: https://github.com/doctrine/dbal/blob/master/.travis.yml#L39 -jobs: - include: - # Different test stages -# - stage: Test -# name: PHP 7.2 + MySQL 5.7 -# php: 7.2 -# env: DB=mysql -# services: -# - mysql -# - stage: Test -# name: PHP 7.3 + MySQL 5.7 -# php: 7.3 -# env: DB=mysql -# services: -# - mysql -# - stage: Test -# name: PHP 7.4 + MySQL 5.7 -# php: 7.4 -# env: DB=mysql -# services: -# - mysql -# - stage: Test -# name: PHP 7.2 + MariaDB 10.1 -# php: 7.2 -# env: DB=mariadb -# addons: -# mariadb: '10.1' -# - stage: Test -# name: PHP 7.3 + MariaDB 10.1 -# php: 7.3 -# env: DB=mariadb -# addons: -# mariadb: '10.1' -# - stage: Test -# name: PHP 7.4 + MariaDB 10.1 -# php: 7.4 -# env: DB=mariadb MARIADB_VERSION=10.1 -# addons: -# mariadb: '10.1' -# - stage: Test -# name: PHP 7.2 + MariaDB 10.2 -# php: 7.2 -# env: DB=mariadb -# addons: -# mariadb: '10.2' -# - stage: Test -# name: PHP 7.3 + MariaDB 10.3 -# php: 7.3 -# env: DB=mariadb -# addons: -# mariadb: '10.2' -# - stage: Test -# name: PHP 7.4 + MariaDB 10.2 -# php: 7.4 -# env: DB=mariadb -# addons: -# mariadb: '10.2' -# - stage: Test -# name: PHP 7.2 + MariaDB 10.3 -# php: 7.2 -# env: DB=mariadb -# addons: -# mariadb: '10.3' -# - stage: Test -# name: PHP 7.3 + MariaDB 10.3 -# php: 7.3 -# env: DB=mariadb -# addons: -# mariadb: '10.3' -# - stage: Test -# name: PHP 7.4 + MariaDB 10.3 -# php: 7.4 -# env: DB=mariadb -# addons: -# mariadb: '10.3' - - # Just packages up a release - - stage: package - script: skip - before_deploy: - - curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash - - # Configure the conditional deployment - # https://docs.travis-ci.com/user/deployment/#examples-of-conditional-deployment - deploy: - - provider: script - skip_cleanup: true - script: ./.travis/deploy_script.sh - on: - all_branches: true - repo: nabeelio/phpvms - php: '7.4' - tags: false - - # RELEASE STAGE - # Only runs when there's a tag applied to this release (tag should be the version) - # This uses Github Releases and posts it there (provider: releases) - # https://docs.travis-ci.com/user/deployment/releases - - stage: release - script: skip - before_deploy: - - curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/6b10798/install | bash - - ./.travis/deploy_script.sh - deploy: - provider: releases - skip_cleanup: true - api_key: $GITHUB_TOKEN - file_glob: true - file: build/* - on: - tags: true - repo: nabeelio/phpvms - php: '7.4' diff --git a/README.md b/README.md index eeeed83d..3af3d95c 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # phpVMS 7 -[](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) +[](https://github.com/nabeelio/phpvms/actions) [](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&utm_medium=referral&utm_content=nabeelio/phpvms&utm_campaign=Badge_Grade) [](https://packagist.org/packages/nabeel/phpvms)  [](https://packagist.org/packages/nabeel/phpvms) The next phpvms version built on the laravel framework. work in progress. The latest documentation, with installation instructions is available [on the phpVMS documentation](https://docs.phpvms.net/) page. diff --git a/app/Console/Commands/DevInstall.php b/app/Console/Commands/DevInstall.php index ad19570b..39b34e48 100644 --- a/app/Console/Commands/DevInstall.php +++ b/app/Console/Commands/DevInstall.php @@ -3,7 +3,7 @@ namespace App\Console\Commands; use App\Contracts\Command; -use Modules\Installer\Services\ConfigService; +use App\Services\Installer\ConfigService; /** * Create a fresh development install diff --git a/app/Database/migrations/2021_01_17_044305_add_hub_to_subfleets.php b/app/Database/migrations/2021_01_17_044305_add_hub_to_subfleets.php new file mode 100644 index 00000000..e71bf1b4 --- /dev/null +++ b/app/Database/migrations/2021_01_17_044305_add_hub_to_subfleets.php @@ -0,0 +1,20 @@ +string('hub_id', 4) + ->nullable() + ->after('airline_id'); + }); + } +} diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php index 7943ee11..b1ff4caa 100644 --- a/app/Http/Controllers/Admin/SubfleetController.php +++ b/app/Http/Controllers/Admin/SubfleetController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Traits\Importable; use App\Http\Requests\CreateSubfleetRequest; use App\Http\Requests\UpdateSubfleetRequest; use App\Models\Airline; +use App\Models\Airport; use App\Models\Enums\FareType; use App\Models\Enums\FuelType; use App\Models\Enums\ImportExportType; @@ -133,6 +134,7 @@ class SubfleetController extends Controller { return view('admin.subfleets.create', [ 'airlines' => Airline::all()->pluck('name', 'id'), + 'hubs' => Airport::where('hub', 1)->pluck('name', 'id'), 'fuel_types' => FuelType::labels(), ]); } @@ -203,6 +205,7 @@ class SubfleetController extends Controller return view('admin.subfleets.edit', [ 'airlines' => Airline::all()->pluck('name', 'id'), + 'hubs' => Airport::where('hub', 1)->pluck('name', 'id'), 'fuel_types' => FuelType::labels(), 'avail_fares' => $avail_fares, 'avail_ranks' => $avail_ranks, diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index 95301b9a..d3e2e79d 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -120,6 +120,7 @@ class FlightController extends Controller 'saved' => $saved_flights, 'subfleets' => $this->subfleetRepo->selectBoxList(true), 'flight_number' => $request->input('flight_number'), + 'flight_type' => $request->input('flight_type'), 'arr_icao' => $request->input('arr_icao'), 'dep_icao' => $request->input('dep_icao'), 'subfleet_id' => $request->input('subfleet_id'), diff --git a/app/Http/Controllers/Frontend/SimBriefController.php b/app/Http/Controllers/Frontend/SimBriefController.php index 7b155db7..580d29e8 100644 --- a/app/Http/Controllers/Frontend/SimBriefController.php +++ b/app/Http/Controllers/Frontend/SimBriefController.php @@ -80,6 +80,29 @@ class SimBriefController ]); } + /** + * Remove the flight_id from the SimBrief Briefing (to a create a new one) + * or if no pirep_id is attached to the briefing delete it completely + * + * @param \Illuminate\Http\Request $request + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + */ + public function remove(Request $request) + { + $sb_pack = SimBrief::find($request->id); + if ($sb_pack) { + if (!$sb_pack->pirep_id) { + $sb_pack->delete(); + } else { + $sb_pack->flight_id = null; + $sb_pack->save(); + } + } + + return redirect(route('frontend.flights.index')); + } + /** * Create a prefile of this PIREP with a given OFP. Then redirect the * user to the newly prefiled PIREP diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 1f95855a..994a79b5 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -97,6 +97,11 @@ class Airline extends Model $this->attributes['icao'] = strtoupper($icao); } + public function subfleets() + { + return $this->hasMany(Subfleet::class, 'airline_id'); + } + public function flights() { return $this->belongsTo(Flight::class, 'airline_id'); diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 58116b5a..0bad6db1 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -8,27 +8,26 @@ use App\Models\Traits\ExpensableTrait; use App\Models\Traits\FilesTrait; /** - * Class Subfleet - * * @property int id * @property string type * @property string name + * @property int airline_id + * @property int hub_id * @property string ground_handling_multiplier * @property Fare[] fares * @property float cost_block_hour * @property float cost_delay_minute * @property Airline airline - * @property int airline_id + * @property Airport hub */ class Subfleet extends Model { use ExpensableTrait; use FilesTrait; - public $table = 'subfleets'; - public $fillable = [ 'airline_id', + 'hub_id', 'type', 'name', 'fuel_type', @@ -40,6 +39,8 @@ class Subfleet extends Model 'gross_weight', ]; + public $table = 'subfleets'; + public $casts = [ 'airline_id' => 'integer', 'turn_time' => 'integer', @@ -55,6 +56,7 @@ class Subfleet extends Model public static $rules = [ 'type' => 'required', 'name' => 'required', + 'hub_id' => 'nullable', 'ground_handling_multiplier' => 'nullable|numeric', ]; @@ -81,6 +83,11 @@ class Subfleet extends Model return $this->belongsTo(Airline::class, 'airline_id'); } + public function hub() + { + return $this->hasOne(Airport::class, 'id', 'hub_id'); + } + public function fares() { return $this->belongsToMany(Fare::class, 'subfleet_fare') diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 6ba793d3..2cdd142c 100755 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -147,6 +147,7 @@ class RouteServiceProvider extends ServiceProvider Route::get('simbrief/{id}', 'SimBriefController@briefing')->name('simbrief.briefing'); Route::get('simbrief/{id}/prefile', 'SimBriefController@prefile')->name('simbrief.prefile'); Route::get('simbrief/{id}/cancel', 'SimBriefController@cancel')->name('simbrief.cancel'); + Route::get('simbrief/{id}/remove', 'SimBriefController@remove')->name('simbrief.remove'); }); Route::group([ diff --git a/app/Repositories/FlightRepository.php b/app/Repositories/FlightRepository.php index 36a7f62b..f74e1e18 100644 --- a/app/Repositories/FlightRepository.php +++ b/app/Repositories/FlightRepository.php @@ -20,6 +20,7 @@ class FlightRepository extends Repository implements CacheableInterface 'arr_airport_id', 'distance', 'dpt_airport_id', + 'flight_type', 'flight_number' => 'like', 'route_code' => 'like', 'route_leg' => 'like', @@ -93,6 +94,10 @@ class FlightRepository extends Repository implements CacheableInterface $where['flight_number'] = $request->input('flight_number'); } + if ($request->filled('flight_type')) { + $where['flight_type'] = $request->input('flight_type'); + } + if ($request->filled('route_code')) { $where['route_code'] = $request->input('route_code'); } diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 4f68311b..c761bcc4 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -6,6 +6,9 @@ use App\Contracts\ImportExport; use App\Contracts\Service; use App\Models\Airport; use App\Models\Expense; +use App\Models\Fare; +use App\Models\Flight; +use App\Models\FlightFieldValue; use App\Repositories\FlightRepository; use App\Services\ImportExport\AircraftImporter; use App\Services\ImportExport\AirportImporter; @@ -209,7 +212,7 @@ class ImportService extends Service public function importFares($csv_file, bool $delete_previous = true) { if ($delete_previous) { - // TODO: Delete all from: fares + Fare::truncate(); } $importer = new FareImporter(); @@ -229,7 +232,8 @@ class ImportService extends Service public function importFlights($csv_file, bool $delete_previous = true) { if ($delete_previous) { - // TODO: Delete all from: flights, flight_field_values + Flight::truncate(); + FlightFieldValue::truncate(); } $importer = new FlightImporter(); diff --git a/app/Widgets/LiveMap.php b/app/Widgets/LiveMap.php index 514c6a8e..dcfaf780 100644 --- a/app/Widgets/LiveMap.php +++ b/app/Widgets/LiveMap.php @@ -14,6 +14,7 @@ class LiveMap extends Widget protected $config = [ 'height' => '800px', 'width' => '100%', + 'table' => true, ]; /** diff --git a/package-lock.json b/package-lock.json index 24624a17..98de0e12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1689,12 +1689,18 @@ "dev": true }, "axios": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", - "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" + "follow-redirects": "^1.10.0" + }, + "dependencies": { + "follow-redirects": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz", + "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==" + } } }, "axobject-query": { @@ -5329,11 +5335,6 @@ "binary-extensions": "^1.0.0" } }, - "is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" - }, "is-callable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", diff --git a/package.json b/package.json index 1fd10007..91d8c3bd 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@turf/center": "^6.0.1", "acorn": "^7.4.1", "animate.css": "~3.6", - "axios": "^0.18.1", + "axios": "^0.21.1", "bootstrap": "~4.3", "bootstrap-sass": "^3.4.1", "bootstrap3": "npm:bootstrap@~3.4", diff --git a/resources/views/admin/flights/search.blade.php b/resources/views/admin/flights/search.blade.php index 4b3ef45b..4d8ea432 100644 --- a/resources/views/admin/flights/search.blade.php +++ b/resources/views/admin/flights/search.blade.php @@ -3,7 +3,9 @@
{{ $errors->first('airline_id') }}
{{ $errors->first('hub_id') }}
+{{ $errors->first('type') }}
{{ $errors->first('name') }}
diff --git a/resources/views/layouts/default/flights/search.blade.php b/resources/views/layouts/default/flights/search.blade.php index b41f4d9d..c0472e4a 100644 --- a/resources/views/layouts/default/flights/search.blade.php +++ b/resources/views/layouts/default/flights/search.blade.php @@ -11,7 +11,29 @@@lang('common.airline')
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}@lang('flights.flightnumber')
{{ Form::text('flight_number', null, ['class' => 'form-control']) }} diff --git a/resources/views/layouts/default/flights/simbrief_briefing.blade.php b/resources/views/layouts/default/flights/simbrief_briefing.blade.php index 82c6141e..f88c97bf 100644 --- a/resources/views/layouts/default/flights/simbrief_briefing.blade.php +++ b/resources/views/layouts/default/flights/simbrief_briefing.blade.php @@ -3,7 +3,7 @@ @section('content')