Compare commits

..

113 Commits

Author SHA1 Message Date
Nabeel Shahzad
dd144cc9bc Update changelog 2018-02-23 11:47:57 -06:00
Nabeel Shahzad
7eef7f6cfe Remove extra header from changelog 2018-02-22 17:00:26 -06:00
Nabeel Shahzad
6332bfc6f3 Updated CHANGELOG 2018-02-22 16:38:58 -06:00
Nabeel Shahzad
b2d91ba4c9 Show how pirep was filed in list/edit 2018-02-22 15:29:25 -06:00
Nabeel Shahzad
53b0bbd936 Convert errors into HttpException calls 2018-02-22 15:15:00 -06:00
Nabeel Shahzad
3748ab77d2 Fix aircraft active/inactive states 2018-02-22 14:59:09 -06:00
Nabeel Shahzad
8931f4e271 Change pirep action colors 2018-02-22 14:55:42 -06:00
Nabeel Shahzad
10b0798a30 Cleanup info callouts into components 2018-02-22 14:21:00 -06:00
Nabeel Shahzad
67f6dfc2f4 Cleanup of icons and removed ones not used #195 2018-02-22 13:28:12 -06:00
Nabeel Shahzad
fc381da21b Clean JS in admin to use const/let instead of var 2018-02-22 11:47:28 -06:00
Nabeel Shahzad
98eef1eb12 Update vendor files with font change 2018-02-22 11:44:19 -06:00
Nabeel Shahzad
72c3191c02 Copyright/license update 2018-02-22 11:37:47 -06:00
Nabeel Shahzad
ad5f36f85e Cleanup frontend user bid add/remove to use the API, script and html cleanup #172 2018-02-22 11:34:57 -06:00
Nabeel Shahzad
6dfab75f08 Add api routes to get/add/remove bids for a user #172 2018-02-22 10:44:15 -06:00
Nabeel Shahzad
e176772512 Rename system.js to phpvms.js to make it clearer 2018-02-22 10:14:45 -06:00
Nabeel Shahzad
487b7480af Refactor how errors are handled 2018-02-22 10:14:12 -06:00
Nabeel Shahzad
5d2ef3a9d3 Fix wrong Exception being thrown 2018-02-22 09:41:23 -06:00
Nabeel Shahzad
7b68642fa3 Checkboxes are the bane of my existence closes #181 2018-02-22 09:36:07 -06:00
Nabeel Shahzad
abf47274a1 Cleanup some class names; move acars data into separate seed file 2018-02-22 09:31:07 -06:00
Nabeel Shahzad
3abf38ab93 Return string if not multi-value; add delete_previous flag #194 2018-02-21 21:42:47 -06:00
Nabeel Shahzad
9ed370693d First pass at csv column parsing for kvp as values #194 2018-02-21 21:38:35 -06:00
Nabeel Shahzad
964ea904a1 Make sure the subfleet type field doesn't have spaces 2018-02-21 20:18:50 -06:00
Nabeel Shahzad
1a54aadc19 Make sure the subfleet name doesn't have spaces 2018-02-21 20:16:49 -06:00
Nabeel Shahzad
7872a6a442 Remove debug stuff in xml converter 2018-02-21 15:25:58 -06:00
Nabeel Shahzad
9dfdc8195d Add flight log to both frontend and admin pirep edit view 2018-02-21 15:24:46 -06:00
Nabeel Shahzad
77055991af Get the correct ordering for flight route on map 2018-02-21 15:15:12 -06:00
Nabeel Shahzad
ec9d00c597 Fix map centering 2018-02-21 15:07:44 -06:00
Nabeel Shahzad
a18c00ee95 Convert sequelpro xml to yaml for import 2018-02-21 15:02:24 -06:00
Nabeel Shahzad
713fd66da6 Fix timezone not populating from lookup closes #182 2018-02-21 14:36:41 -06:00
Nabeel Shahzad
ea09a18956 Fixed formatting of almost every file 2018-02-20 22:33:09 -06:00
Nabeel Shahzad
c5b6ca53fa Redirect subfleet create to edit page 2018-02-20 21:55:01 -06:00
Nabeel Shahzad
14d04604cb Add ranks from the subfleet edit page closes #160 2018-02-20 21:53:50 -06:00
Nabeel Shahzad
1c143f3b23 subfleet table fix and edit in name 2018-02-20 21:30:36 -06:00
Nabeel Shahzad
bac829b425 Shrink decimal field sizes as they're overly large 2018-02-20 15:57:31 -06:00
Nabeel Shahzad
7185f6cedf Restrict max number in factory, might be hitting 32 bit limit in tests 2018-02-20 15:41:05 -06:00
Nabeel Shahzad
8386951511 Rename toInt to toNumber 2018-02-20 15:32:49 -06:00
Nabeel Shahzad
b9e88527dd Unit conversion fixes #193 2018-02-20 14:23:02 -06:00
Nabeel Shahzad
aeacd80bcb Check aircraft permissions in PIREP update/file 2018-02-20 14:14:20 -06:00
Nabeel Shahzad
653711fa96 Change volume units to be in lbs/kg closes #193 2018-02-20 14:07:33 -06:00
Nabeel Shahzad
463de8d7e7 Make sure the rank restriction disabled works closes #170 2018-02-20 13:28:53 -06:00
Nabeel Shahzad
4e43223f3a Refuse pirep prefile is user not allowed to use aircraft #170 2018-02-20 12:59:49 -06:00
Nabeel Shahzad
8393ae2851 Add /flight/:id/route resource, returns all route info that's in the navaid database closes #183 2018-02-20 12:06:52 -06:00
Nabeel Shahzad
fdf18cf533 Remove raw_data field from pireps closes #188 2018-02-20 11:17:34 -06:00
Nabeel Shahzad
5ee8c1e779 level not required in prefile; distance required in file 2018-02-20 11:12:50 -06:00
Nabeel Shahzad
2955f93573 Fix a few items in composer.json 2018-02-19 21:56:41 -06:00
Nabeel Shahzad
bc8c5e581c Updated lock file 2018-02-19 20:58:32 -06:00
Nabeel Shahzad
ad4259625c Add flight time to flight create/edit form 2018-02-19 13:33:26 -06:00
Nabeel Shahzad
246c828d7a Remove extra level field and fix documentation link 2018-02-19 11:26:11 -06:00
Nabeel Shahzad
3d55fc09f7 Add options field on setting data import 2018-02-19 11:19:18 -06:00
Nabeel Shahzad
1bb77e1d4b Upgrade to Laravel 5.6 #165 2018-02-19 11:09:56 -06:00
Nabeel Shahzad
3d9d17d9b9 Add call to get user's PIREPs #192 2018-02-19 10:35:49 -06:00
Nabeel Shahzad
5c58dfe1ae generate a hex code for an aircraft on creation #33 2018-02-12 20:58:23 -06:00
Nabeel Shahzad
2678514077 API: Only show active airlines 2018-02-12 12:05:10 -06:00
Nabeel Shahzad
ee71f4a1c8 Remove tail_number field from aircraft 2018-02-12 11:03:25 -06:00
Nabeel Shahzad
62506a26a1 set country on the airline, in admin and installer #191 2018-02-12 10:51:04 -06:00
Nabeel Shahzad
61dc0a046d Fix rank image field 2018-02-12 10:26:27 -06:00
Nabeel Shahzad
c817d1ae4b Installer fixes 2018-02-12 09:47:12 -06:00
Nabeel Shahzad
ecfda6de15 Add collision for test listeners and remove one old dep 2018-02-12 09:02:05 -06:00
Nabeel Shahzad
2f8a69b774 Undo casting time types to Time object #189 2018-02-11 20:50:48 -06:00
Nabeel Shahzad
61af5fe226 Cleanup column types and assign Time class to fields #189 2018-02-11 20:38:56 -06:00
Nabeel Shahzad
fd4407a798 Move internal unit definitions to config file #189 2018-02-11 20:19:02 -06:00
Nabeel Shahzad
4eef254688 set nautical miles as the default mass unit #189 2018-02-11 19:58:07 -06:00
Nabeel Shahzad
d5c2d25c74 finally fixed serialization of conversions #189 2018-02-10 22:49:08 -06:00
Nabeel Shahzad
0700c96901 fix serialization of converter classes #189 2018-02-10 22:30:42 -06:00
Nabeel Shahzad
9b9a20b437 set default storage unit #189 2018-02-10 22:18:07 -06:00
Nabeel Shahzad
f14a9e3ba1 implements ArrayAccess for casting to type #189 2018-02-10 22:04:30 -06:00
Nabeel Shahzad
cb02a7c15e add Time support class #189 2018-02-10 21:36:13 -06:00
Nabeel Shahzad
a8e06c6cc6 base conversion classes for units #189 2018-02-10 21:16:32 -06:00
Nabeel Shahzad
176855b680 check if airport exists 2018-02-10 20:30:11 -06:00
Nabeel Shahzad
3aa01aaa18 tests check the data object in return #186 2018-02-10 18:17:38 -06:00
Nabeel Shahzad
04d44d9bd7 Add SKIN_NAME to error message pages #187 2018-02-10 17:58:11 -06:00
Nabeel Shahzad
762544ea6f don't change rank if it's not auto promoted #168 2018-02-10 17:53:25 -06:00
Nabeel Shahzad
2a289e0468 pirep route wrap the data object #186 2018-02-10 17:48:51 -06:00
Nabeel Shahzad
21e13b6b92 make sure resources return the data object #186 2018-02-10 17:34:46 -06:00
Nabeel Shahzad
e57fb5a7c6 Move code of conduct to wiki 2018-02-10 17:31:59 -06:00
Nabeel Shahzad
5a89b4f194 write the route if it hasn't been set by acars #184 2018-02-10 16:10:19 -06:00
Nabeel Shahzad
7a6b228d8f make planned_distance optional #185 2018-02-10 16:02:15 -06:00
Nabeel Shahzad
fbd73b0717 make planned_distance optional #185 2018-02-10 16:00:43 -06:00
Nabeel Shahzad
7a527f2ed3 Set access modifier on all enums (php 7.1) 2018-02-10 14:06:25 -06:00
Nabeel Shahzad
e6290c3396 set pirep source to acars #177 2018-02-10 13:41:24 -06:00
Nabeel Shahzad
8acb9291fe hide all cancelled pireps #180 2018-02-10 13:25:40 -06:00
Nabeel Shahzad
3ded06390c ignore cancelled pireps in dupe check #179 2018-02-10 13:12:12 -06:00
Nabeel Shahzad
936bceba5d Add --reset-db flag to phpvms:dev-install command #176 2018-02-09 17:16:52 -06:00
Nabeel Shahzad
d94294e3f6 Added new phpvms:dev-install command #176 2018-02-09 17:11:55 -06:00
Nabeel Shahzad
390f08d25f Cleanup the sample env.php file 2018-02-09 16:36:02 -06:00
Nabeel Shahzad
f0d2b4ed2f update changelog 2018-02-09 15:44:36 -06:00
Nabeel Shahzad
80cd80a5cf Change the filtering to operate without being in the service layer #174 2018-02-09 15:42:37 -06:00
Nabeel Shahzad
17f1085ffb Filter out flights depending on the only_flights_from_current setting #174 2018-02-09 15:36:13 -06:00
Nabeel Shahzad
9b55a9691f Setting which filters out aircraft not at the departure airport #171 2018-02-09 15:07:34 -06:00
Nabeel Shahzad
13b4a3854b move filterSubfleets() to FlightService class #170 2018-02-09 14:36:36 -06:00
Nabeel Shahzad
f6b2102e48 fix bug where aircraft restrictions aren't respected in flight calls #170 2018-02-09 14:26:14 -06:00
Nabeel Shahzad
71189e4f2d Change most APIs to require API key #173 2018-02-09 13:20:35 -06:00
Nabeel Shahzad
041cef91de Refactor how settings are added to generate the offsets and order 2018-02-09 12:57:00 -06:00
Nabeel Shahzad
2a0e97c043 update composer 2018-02-08 19:16:03 -06:00
Nabeel Shahzad
bcc6be0d29 Updates for addon/modules to make it easier to create APIs 2018-02-08 19:11:53 -06:00
Nabeel Shahzad
b4ea82f327 Cleanup of the test classes and remove superfluous dependencies 2018-02-08 11:07:21 -06:00
Nabeel Shahzad
48346ae805 Use migrate:fresh instead of refresh 2018-02-07 10:37:54 -06:00
Nabeel Shahzad
b5dbde84c4 Fix rank image link field to be string 2018-02-06 14:09:20 -06:00
Nabeel Shahzad
e69d9f4c38 Add pirep fields to the API response; add tests for setting/getting them 2018-02-06 13:59:40 -06:00
Nabeel Shahzad
de0c71cb06 Set fields to pireps in prefile/update calls 2018-02-06 13:46:23 -06:00
Nabeel Shahzad
8b2eddc72d Travis build distros on PHP 7.1 2018-02-06 13:13:45 -06:00
Nabeel Shahzad
cf286986e2 change variable name 2018-02-06 13:13:00 -06:00
Nabeel Shahzad
7d8dc2a4d4 Cleanup factories and seed data for airport timezone column change 2018-02-06 13:11:42 -06:00
Nabeel Shahzad
531c7ddba3 Set hours to read-only once they've changed away from PENDING #167 2018-02-06 12:58:48 -06:00
Nabeel Shahzad
ac0058e951 Some more attribute cleanup 2018-02-06 12:01:55 -06:00
Nabeel Shahzad
56bf277fe0 Add shorthands for timezone to tz 2018-02-06 11:02:40 -06:00
Nabeel Shahzad
1cc999a4f9 Change Airport tz field to timezone 2018-02-06 10:59:31 -06:00
Nabeel Shahzad
c6b1a475e9 Add timezone aliases 2018-02-06 10:33:39 -06:00
Nabeel Shahzad
8d76e16220 Add the validation error fields in the templates 2018-02-06 10:18:22 -06:00
Nabeel Shahzad
995d53df3e Set slug properly on pirep field and fix validation 2018-02-06 10:02:34 -06:00
Nabeel Shahzad
282421deb8 Add a /update to update an install #164 2018-02-05 16:16:24 -06:00
Nabeel Shahzad
eebf7871cb Cleanup composer file and reqs in readme #166 2018-02-05 13:26:54 -06:00
Nabeel Shahzad
9d46cee07a Bump minimum PHP version to 7.1; library cleanup #166 2018-02-05 11:29:50 -06:00
326 changed files with 21331 additions and 11124 deletions

View File

@@ -1,8 +1,8 @@
language: php
php:
- '7.0'
#- '7.0'
- '7.1'
#- '7.2'
- '7.2'
#- nightly
cache:
@@ -12,7 +12,6 @@ cache:
services:
- mysql
#- redis-server
before_script:
- cp .travis/env.travis.php env.php
@@ -39,7 +38,7 @@ jobs:
script: ./.travis/deploy_script.sh
on:
all_branches: true
php: '7.0'
php: '7.1'
- stage: release
script: skip
before_deploy:
@@ -55,4 +54,4 @@ jobs:
on:
tags: true
repo: nabeelio/phpvms
php: '7.0'
php: '7.1'

View File

@@ -18,6 +18,9 @@
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<listeners>
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
</listeners>
<php>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="On"/>

View File

@@ -1,8 +1,49 @@
# Changelog
## Alpha 2 (2018-02-23, v7.0.0-alpha2)
## [Unreleased]
!! Please do a full reinstall, with recreating the database
## 7.0.0-alpha1
- 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)
### Added
- Initial release
#### 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)
- Initial Release

View File

@@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at gm@nabs.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2017, phpvms
Copyright (c) 2017, phpvms - http://www.phpvms.net
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -60,8 +60,9 @@ reset: clean
.PHONY: reload-db
reload-db:
@php artisan database:create --reset
@php artisan migrate:refresh --seed
@php artisan migrate:fresh --seed
@php artisan phpvms:import app/Database/seeds/sample.yml
@php artisan phpvms:import app/Database/seeds/acars.yml
#php artisan phpvms:navdata
.PHONY: tests

View File

@@ -15,7 +15,7 @@ The latest documentation, with installation instructions is available
## Requirements
- PHP 7.0+, extensions:
- PHP 7.1+, extensions:
- cURL
- JSON
- mbstring

View File

@@ -2,8 +2,8 @@
namespace App\Bootstrap;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Config\Repository as RepositoryContract;
use Illuminate\Contracts\Foundation\Application;
/**
* Class LoadConfiguration

View File

@@ -2,11 +2,10 @@
namespace App\Console\Commands;
use Illuminate\Database\Eloquent\Collection;
use GuzzleHttp\Client;
use App\Console\BaseCommand;
use App\Facades\Utils;
use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Collection;
class AcarsReplay extends BaseCommand
{

View File

@@ -2,9 +2,8 @@
namespace App\Console\Commands;
use Log;
use App\Console\BaseCommand;
use Log;
class CreateDatabase extends BaseCommand
{

View File

@@ -2,19 +2,18 @@
namespace App\Console\Commands;
use DB;
use PDO;
use App\Models\Airline;
use App\Models\User;
use App\Console\BaseCommand;
use App\Models\Acars;
use App\Models\Airline;
use App\Models\Pirep;
use App\Models\User;
use DB;
use PDO;
use Symfony\Component\Yaml\Yaml;
class DevCommands extends BaseCommand
{
protected $signature = 'phpvms {cmd}';
protected $signature = 'phpvms {cmd} {param?}';
protected $description = 'Developer commands';
/**
@@ -34,6 +33,7 @@ class DevCommands extends BaseCommand
'clear-users' => 'clearUsers',
'compile-assets' => 'compileAssets',
'db-attrs' => 'dbAttrs',
'xml-to-yaml' => 'xmlToYaml',
];
if(!array_key_exists($command, $commands)) {
@@ -108,4 +108,42 @@ class DevCommands extends BaseCommand
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate_prepares);
}
/**
* Convert the sequelpro xml export to yaml
*/
protected function xmlToYaml()
{
$file = $this->argument('param');
$this->info('Reading '. $file);
$xml_str = file_get_contents($file);
$xml = new \SimpleXMLElement($xml_str);
$yaml = [];
$table_name = (string) $xml->database->table_data['name'];
$this->info('Writing table "'.$table_name.'"');
$count = 0;
$yaml[$table_name] = [];
foreach ($xml->database->table_data->row as $row) {
$yaml_row = [];
foreach($row->field as $field) {
$fname = (string) $field['name'];
$fvalue = (string) $field;
$yaml_row[$fname] = $fvalue;
}
$yaml[$table_name][] = $yaml_row;
++$count;
}
$this->info('Exporting '.$count.' rows');
$file_name = $table_name.'.yml';
file_put_contents(storage_path($file_name), Yaml::dump($yaml, 4, 2));
$this->info('Writing yaml to storage: '. $file_name);
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace App\Console\Commands;
use App\Console\BaseCommand;
use Modules\Installer\Services\ConfigService;
/**
* Create a fresh development install
* @package App\Console\Commands
*/
class DevInstall extends BaseCommand
{
protected $signature = 'phpvms:dev-install {--reset-db}';
protected $description = 'Run a developer install and run the sample migration';
/**
* Run dev related commands
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*/
public function handle()
{
if(!$this->option('reset-db')) {
$this->rewriteConfigs();
}
# Reload the configuration
\App::boot();
$this->info('Recreating database');
\Artisan::call('database:create', [
'--reset' => true,
]);
$this->info(\Artisan::output());
#
#
$this->info('Running migrations');
\Artisan::call('migrate:fresh', [
'--seed' => true,
]);
$this->info(\Artisan::output());
#
#
$this->info('Importing sample data');
\Artisan::call('phpvms:import', [
'files' => ['app/Database/seeds/sample.yml'],
]);
$this->info(\Artisan::output());
$this->info('Done!');
}
/**
* Rewrite the configuration files
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*/
protected function rewriteConfigs()
{
$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);
}
$this->info('Removing the sqlite db');
$db_file = storage_path('db.sqlite');
if(file_exists($db_file)) {
unlink($db_file);
}
$this->info('Regenerating the config files');
$cfgSvc->createConfigFiles([
'APP_ENV' => 'dev',
'SITE_NAME' => 'phpvms test',
'DB_CONN' => 'sqlite',
]);
$this->info('Config files generated!');
}
}

View File

@@ -2,10 +2,9 @@
namespace App\Console\Commands;
use DB;
use App\Console\BaseCommand;
class Importer extends BaseCommand
class ImportFromClassic extends BaseCommand
{
protected $signature = 'phpvms:importer {db_host} {db_name} {db_user} {db_pass?} {table_prefix=phpvms_}';
protected $description = 'Import from an older version of phpVMS';

View File

@@ -3,11 +3,10 @@
namespace App\Console\Commands;
use App\Console\BaseCommand;
use App\Models\Navdata;
use App\Models\Enums\NavaidType;
use App\Models\Navdata;
class NavdataCommand extends BaseCommand
class NavdataImport extends BaseCommand
{
protected $signature = 'phpvms:navdata';
protected $description = '';

View File

@@ -2,8 +2,8 @@
namespace App\Console\Commands;
use GuzzleHttp\Client;
use App\Console\BaseCommand;
use GuzzleHttp\Client;
class TestApi extends BaseCommand
{

View File

@@ -2,11 +2,10 @@
namespace App\Console\Commands;
use DB;
use App\Console\BaseCommand;
use App\Services\DatabaseService;
class ImportCommand extends BaseCommand
class YamlImport extends BaseCommand
{
protected $signature = 'phpvms:import {files*}';
protected $description = 'Developer commands';

View File

@@ -16,10 +16,10 @@ class Kernel extends ConsoleKernel
Commands\AcarsReplay::class,
Commands\CreateDatabase::class,
Commands\DevCommands::class,
Commands\ImportCommand::class,
Commands\Importer::class,
Commands\YamlImport::class,
Commands\ImportFromClassic::class,
Commands\Install::class,
Commands\NavdataCommand::class,
Commands\NavdataImport::class,
Commands\TestApi::class,
];

View File

@@ -2,8 +2,8 @@
namespace App\Console\Services;
use PDO;
use Doctrine\DBAL\Driver\PDOException;
use PDO;
/**
* Class Database

View File

@@ -2,26 +2,25 @@
namespace App\Console\Services;
use PDO;
use Carbon\Carbon;
use Doctrine\DBAL\Driver\PDOException;
use Illuminate\Support\Str;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Symfony\Component\Console\Output\ConsoleOutput;
use App\Models\Enums\FlightType;
use App\Models\Enums\PirepSource;
use App\Models\Pirep;
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 App\Models\Enums\UserState;
use App\Facades\Utils;
use Carbon\Carbon;
use Doctrine\DBAL\Driver\PDOException;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use PDO;
use Symfony\Component\Console\Output\ConsoleOutput;
/**
* Class Importer

View File

@@ -4,7 +4,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 100000),
'id' => null,
'subfleet_id' => function() {
return factory(App\Models\Subfleet::class)->create()->id;
},
@@ -14,7 +14,7 @@ $factory->define(App\Models\Aircraft::class, function (Faker $faker) {
'icao' => $faker->unique()->text(5),
'name' => $faker->unique()->text(50),
'registration' => $faker->unique()->text(10),
'tail_number' => $faker->unique()->text(10),
'hex_code' => \App\Support\ICAO::createHexCode(),
'active' => true,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $pirep) {

View File

@@ -8,7 +8,7 @@ use Hashids\Hashids;
*/
$factory->define(App\Models\Airline::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'icao' => function (array $apt) use ($faker) {
$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));

View File

@@ -1,6 +1,5 @@
<?php
use Hashids\Hashids;
use Faker\Generator as Faker;
/**
@@ -9,7 +8,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Airport::class, function (Faker $faker) {
return [
'id' => function(array $apt) use ($faker) {
'id' => function() {
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$string = '';
$max = strlen($characters) - 1;
@@ -18,16 +17,12 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
}
return $string;
#return $faker->unique()->text(5);
/*$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));
return $hashids->encode($mt);*/
},
'icao' => function(array $apt) { return $apt['id']; },
'iata' => function (array $apt) { return $apt['id']; },
'name' => $faker->sentence(3),
'country' => $faker->country,
'tz' => $faker->timezone,
'timezone' => $faker->timezone,
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'fuel_100ll_cost' => $faker->randomFloat(2),

View File

@@ -4,7 +4,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Fare::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'code' => $faker->text(5),
'name' => $faker->text(20),
'price' => $faker->randomFloat(2, 100, 1000),

View File

@@ -8,8 +8,10 @@ $airlinesAvailable = [1];
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
return [
'id' => substr($faker->unique()->sha1, 28, 12),
'airline_id' => $faker->randomElement($airlinesAvailable),
'id' => null,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
'route_code' => $faker->randomElement(['', $faker->text(5)]),
'route_leg' => $faker->randomElement(['', $faker->text(5)]),
@@ -22,15 +24,16 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) use ($airline
'alt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'route' => $faker->randomElement(['', $faker->text(5)]),
'distance' => $faker->numberBetween(0, 3000),
'route' => null,
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->randomFloat(2),
'flight_time' => $faker->numberBetween(60, 360),
'has_bid' => false,
'active' => true,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $pirep) {
return $pirep['created_at'];
'updated_at' => function (array $flight) {
return $flight['created_at'];
},
];
});

View File

@@ -6,7 +6,7 @@ use \App\Models\Enums\NavaidType;
$factory->define(App\Models\Navdata::class, function (Faker $faker) {
return [
'id' => str_replace(' ', '', str_replace('.', '', $faker->unique()->text(5))),
'name' => $faker->unique()->text(10),
'name' => str_replace('.', '', $faker->unique()->word),
'type' => $faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
'lat' => $faker->latitude,
'lon' => $faker->longitude,

View File

@@ -8,28 +8,24 @@ use Faker\Generator as Faker;
*/
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
static $raw_data;
return [
'id' => null,
'airline_id' => function () { # OVERRIDE THIS IF NEEDED
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'user_id' => function () { # OVERRIDE THIS IF NEEDED
'user_id' => function () {
return factory(App\Models\User::class)->create()->id;
},
'aircraft_id' => function () {
return factory(App\Models\Aircraft::class)->create()->id;
},
'flight_number' => function () {
return factory(App\Models\Flight::class)->create()->flight_number;
},
'route_code' => function(array $pirep) {
//return App\Models\Flight::where(['flight_number' => $pirep['flight_number']])->first()->route_code;
},
'route_leg' => function (array $pirep) {
//return App\Models\Flight::where('flight_number', $pirep['flight_number'])->first()->route_leg;
'flight_number' => function (array $pirep) {
return factory(App\Models\Flight::class)->create([
'airline_id' => $pirep['airline_id']
])->flight_number;
},
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
@@ -37,20 +33,19 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
return factory(App\Models\Airport::class)->create()->id;
},
'level' => $faker->numberBetween(20, 400),
'distance' => $faker->randomFloat(2),
'planned_distance' => $faker->randomFloat(2),
'flight_time' => $faker->randomFloat(2),
'planned_flight_time' => $faker->randomFloat(2),
'distance' => $faker->randomFloat(2, 0, 6000),
'planned_distance' => $faker->randomFloat(2, 0, 6000),
'flight_time' => $faker->numberBetween(60, 360),
'planned_flight_time' => $faker->numberBetween(60, 360),
'zfw' => $faker->randomFloat(2),
'block_fuel' => $faker->randomFloat(2),
'fuel_used' => $faker->randomFloat(2),
'block_fuel' => $faker->randomFloat(2, 0, 30000),
'fuel_used' => $faker->randomFloat(2, 0, 30000),
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'source_name' => 'Test Factory',
'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED,
'raw_data' => $raw_data ?: $raw_data = json_encode(['key' => 'value']),
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => function(array $pirep) {
return $pirep['created_at'];

View File

@@ -11,7 +11,7 @@ use Faker\Generator as Faker;
*/
$factory->define(App\Models\Rank::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'name' => $faker->unique()->text(50),
'hours' => $faker->numberBetween(10, 50),
'auto_approve_acars' => 0,

View File

@@ -4,8 +4,10 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'airline_id' => 1,
'id' => null,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'name' => $faker->unique()->text(50),
'type' => $faker->unique()->text(7),
];

View File

@@ -8,7 +8,7 @@ $factory->define(App\Models\User::class, function (Faker $faker)
static $password;
return [
#'id' => $faker->unique()->numberBetween(10, 10000),
'id' => null,
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'),

View File

@@ -14,7 +14,9 @@ class CreateSettingsTable extends Migration
{
Schema::create('settings', function (Blueprint $table) {
$table->string('id');
$table->unsignedInteger('offset')->default(0);
$table->unsignedInteger('order')->default(99);
$table->string('key');
$table->string('name');
$table->string('value');
$table->string('default')->nullable();
@@ -24,219 +26,185 @@ class CreateSettingsTable extends Migration
$table->string('description')->nullable();
$table->primary('id');
$table->index('key');
$table->timestamps();
});
$this->addCounterGroups([
'general' => 1,
'flights' => 20,
'finances' => 40,
'bids' => 60,
'pireps' => 80,
'pilots' => 100,
]);
/**
* Initial default settings
*/
$settings = [
[
'id' => $this->formatSettingId('general.start_date'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Start Date',
'group' => 'general',
'value' => '',
'type' => 'date',
'description' => 'The date your VA started',
],
[
'id' => $this->formatSettingId('general.admin_email'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Admin Email',
'group' => 'general',
'value' => '',
'type' => 'text',
'description' => 'Email where notices, etc are sent',
],
[
'id' => $this->formatSettingId('general.currency'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Currency to Use',
'group' => 'general',
'value' => 'dollar',
'type' => 'select',
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
'description' => 'Currency to show in the interface',
],
[
'id' => $this->formatSettingId('general.distance_unit'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Distance Units',
'group' => 'general',
'value' => 'nm',
'type' => 'select',
'options' => 'km,mi,nm',
'description' => 'The distance unit to show',
],
[
'id' => $this->formatSettingId('general.weight_unit'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Weight Units',
'group' => 'general',
'value' => 'kg',
'type' => 'select',
'options' => 'lbs, kg',
'description' => 'The weight unit',
],
[
'id' => $this->formatSettingId('general.speed_unit'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Speed Units',
'group' => 'general',
'value' => 'Km/H',
'type' => 'select',
'options' => 'Km/H,kts',
'description' => 'The speed unit',
],
[
'id' => $this->formatSettingId('general.altitude_unit'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Altitude Units',
'group' => 'general',
'value' => 'ft',
'type' => 'select',
'options' => 'ft,m',
'description' => 'The altitude units',
],
[
'id' => $this->formatSettingId('general.liquid_unit'),
'order' => $this->getNextOrderNumber('general'),
'name' => 'Liquid Units',
'group' => 'general',
'value' => 'lbs',
'type' => 'select',
'options' => 'liters,gal,kg,lbs',
'description' => 'The liquid units',
],
/**
* BIDS
*/
$this->addSetting('general.start_date', [
'name' => 'Start Date',
'group' => 'general',
'value' => '',
'type' => 'date',
'description' => 'The date your VA started',
]);
[
'id' => $this->formatSettingId('bids.disable_flight_on_bid'),
'order' => $this->getNextOrderNumber('bids'),
'name' => 'Disable flight on bid',
'group' => 'bids',
'value' => true,
'type' => 'boolean',
'description' => 'When a flight is bid on, no one else can bid on it',
],
[
'id' => $this->formatSettingId('bids.allow_multiple_bids'),
'order' => $this->getNextOrderNumber('bids'),
'name' => 'Allow multiple bids',
'group' => 'bids',
'value' => true,
'type' => 'boolean',
'description' => 'Whether or not someone can bid on multiple flights',
],
$this->addSetting('general.admin_email', [
'name' => 'Admin Email',
'group' => 'general',
'value' => '',
'type' => 'text',
'description' => 'Email where notices, etc are sent',
]);
/**
* FINANCES
*/
$this->addSetting('general.currency', [
'name' => 'Currency to Use',
'group' => 'general',
'value' => 'dollar',
'type' => 'select',
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
'description' => 'Currency to show in the interface',
]);
/**
* PIREPS
*/
$this->addSetting('general.distance_unit', [
'name' => 'Distance Units',
'group' => 'general',
'value' => 'NM',
'type' => 'select',
'options' => 'km,mi,NM',
'description' => 'The distance unit to show',
]);
[
'id' => $this->formatSettingId('pireps.duplicate_check_time'),
'order' => $this->getNextOrderNumber('pireps'),
'name' => 'PIREP duplicate time check',
'group' => 'pireps',
'value' => 10,
'default' => 10,
'type' => 'int',
'description' => 'The time in minutes to check for a duplicate PIREP',
],
[
'id' => $this->formatSettingId('pireps.hide_cancelled_pireps'),
'order' => $this->getNextOrderNumber('pireps'),
'name' => 'Hide Cancelled PIREPs',
'group' => 'pireps',
'value' => true,
'default' => true,
'type' => 'boolean',
'description' => 'Hide any cancelled PIREPs in the front-end',
],
$this->addSetting('general.weight_unit', [
'name' => 'Weight Units',
'group' => 'general',
'value' => 'lbs',
'type' => 'select',
'options' => 'lbs,kg',
'description' => 'The weight unit',
]);
[
'id' => $this->formatSettingId('pireps.restrict_aircraft_to_rank'),
'order' => $this->getNextOrderNumber('pireps'),
'name' => 'Restrict Aircraft to Ranks',
'group' => 'pireps',
'value' => true,
'default' => true,
'type' => 'boolean',
'description' => 'Aircraft that can be flown are restricted to a user\'s rank',
],
$this->addSetting('general.speed_unit', [
'name' => 'Speed Units',
'group' => 'general',
'value' => 'knot',
'type' => 'select',
'options' => 'km/h,knot',
'description' => 'The speed unit',
]);
$this->addSetting('general.altitude_unit', [
'name' => 'Altitude Units',
'group' => 'general',
'value' => 'ft',
'type' => 'select',
'options' => 'ft,m',
'description' => 'The altitude units',
]);
/**
* PILOTS
*/
$this->addSetting('general.fuel_unit', [
'name' => 'Fuel Units',
'group' => 'general',
'value' => 'lbs',
'type' => 'select',
'options' => 'lbs,kg',
'description' => 'The units for fuel',
]);
[
'id' => $this->formatSettingId('pilots.id_length'),
'order' => $this->getNextOrderNumber('pilots'),
'name' => 'Pilot ID Length',
'group' => 'pilots',
'value' => 4,
'default' => 4,
'type' => 'int',
'description' => 'The length of a pilot\'s ID',
],
[
'id' => $this->formatSettingId('pilot.auto_accept'),
'order' => $this->getNextOrderNumber('pilots'),
'name' => 'Auto Accept New Pilot',
'group' => 'pilots',
'value' => true,
'type' => 'boolean',
'description' => 'Automatically accept a pilot when they register',
],
[
'id' => $this->formatSettingId('pilots.only_flights_from_current'),
'order' => $this->getNextOrderNumber('pilots'),
'name' => 'Flights from Current',
'group' => 'pilots',
'value' => false,
'type' => 'boolean',
'description' => 'Only show/allow flights from their current location',
],
[
'id' => $this->formatSettingId('pilot.auto_leave_days'),
'order' => $this->getNextOrderNumber('pilots'),
'name' => 'Pilot to ON LEAVE days',
'group' => 'pilots',
'value' => 30,
'default' => 30,
'type' => 'int',
'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity',
],
[
'id' => $this->formatSettingId('pilots.hide_inactive'),
'order' => $this->getNextOrderNumber('pilots'),
'name' => 'Hide Inactive Pilots',
'group' => 'pilots',
'value' => true,
'type' => 'boolean',
'description' => 'Don\'t show inactive pilots in the public view',
],
];
/**
* BIDS
*/
$this->addData('settings', $settings);
$this->addSetting('bids.disable_flight_on_bid', [
'name' => 'Disable flight on bid',
'group' => 'bids',
'value' => true,
'type' => 'boolean',
'description' => 'When a flight is bid on, no one else can bid on it',
]);
$this->addSetting('bids.allow_multiple_bids', [
'name' => 'Allow multiple bids',
'group' => 'bids',
'value' => true,
'type' => 'boolean',
'description' => 'Whether or not someone can bid on multiple flights',
]);
/**
* PIREPS
*/
$this->addSetting('pireps.duplicate_check_time', [
'name' => 'PIREP duplicate time check',
'group' => 'pireps',
'value' => 10,
'type' => 'int',
'description' => 'The time in minutes to check for a duplicate PIREP',
]);
/*$this->addSetting('pireps.hide_cancelled_pireps', [
'name' => 'Hide Cancelled PIREPs',
'group' => 'pireps',
'value' => true,
'type' => 'boolean',
'description' => 'Hide any cancelled PIREPs in the front-end',
]);*/
$this->addSetting('pireps.restrict_aircraft_to_rank', [
'name' => 'Restrict Aircraft to Ranks',
'group' => 'pireps',
'value' => true,
'type' => 'boolean',
'description' => 'Aircraft that can be flown are restricted to a user\'s rank',
]);
$this->addSetting('pireps.only_aircraft_at_dep_airport', [
'name' => 'Restrict Aircraft At Departure',
'group' => 'pireps',
'value' => false,
'type' => 'boolean',
'description' => 'Only allow aircraft that are at the departure airport',
]);
/**
* PILOTS
*/
$this->addSetting('pilots.id_length', [
'name' => 'Pilot ID Length',
'group' => 'pilots',
'value' => 4,
'default' => 4,
'type' => 'int',
'description' => 'The length of a pilot\'s ID',
]);
$this->addSetting('pilot.auto_accept', [
'name' => 'Auto Accept New Pilot',
'group' => 'pilots',
'value' => true,
'type' => 'boolean',
'description' => 'Automatically accept a pilot when they register',
]);
$this->addSetting('pilots.only_flights_from_current', [
'name' => 'Flights from Current',
'group' => 'pilots',
'value' => false,
'type' => 'boolean',
'description' => 'Only show/allow flights from their current location',
]);
$this->addSetting('pilot.auto_leave_days', [
'name' => 'Pilot to ON LEAVE days',
'group' => 'pilots',
'value' => 30,
'default' => 30,
'type' => 'int',
'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity',
]);
$this->addSetting('pilots.hide_inactive', [
'name' => 'Hide Inactive Pilots',
'group' => 'pilots',
'value' => true,
'type' => 'boolean',
'description' => 'Don\'t show inactive pilots in the public view',
]);
}
/**

View File

@@ -1,8 +1,8 @@
<?php
use App\Models\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
@@ -24,11 +24,11 @@ class CreateUsersTable extends Migration
$table->string('country', 2)->nullable();
$table->string('home_airport_id', 5)->nullable();
$table->string('curr_airport_id', 5)->nullable();
$table->string('last_pirep_id', 12)->nullable();
$table->string('last_pirep_id', \App\Models\Pirep::ID_MAX_LENGTH)->nullable();
$table->unsignedBigInteger('flights')->default(0);
$table->unsignedBigInteger('flight_time')->nullable()->default(0);
$table->unsignedBigInteger('transfer_time')->nullable()->default(0);
$table->decimal('balance', 19)->nullable();
$table->decimal('balance')->nullable();
$table->string('timezone', 64)->nullable();
$table->unsignedTinyInteger('status')->nullable()->default(0);
$table->unsignedTinyInteger('state')->nullable()->default(0);

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSessionsTable extends Migration
{

View File

@@ -1,7 +1,6 @@
<?php
use \App\Models\Enums\AircraftState;
use App\Models\Enums\AircraftState;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
@@ -15,11 +14,10 @@ class CreateAircraftsTable extends Migration
$table->string('icao', 4)->nullable();
$table->string('airport_id', 5)->nullable();
$table->timestamp('landing_time')->nullable();
$table->string('hex_code', 10)->nullable();
$table->string('name', 50);
$table->string('registration', 10)->nullable();
$table->string('tail_number', 10)->nullable();
$table->unsignedDecimal('zfw', 12)->nullable()->default(0);
$table->string('hex_code', 10)->nullable();
$table->unsignedDecimal('zfw')->nullable()->default(0);
$table->unsignedBigInteger('flight_time')->nullable()->default(0);
$table->boolean('active')->default(true);
$table->unsignedTinyInteger('state')->default(AircraftState::PARKED);

View File

@@ -17,8 +17,8 @@ class CreateFaresTable extends Migration
$table->increments('id');
$table->string('code', 50);
$table->string('name', 50);
$table->unsignedDecimal('price', 19)->nullable()->default(0.00);
$table->unsignedDecimal('cost', 19)->nullable()->default(0.00);
$table->unsignedDecimal('price')->nullable()->default(0.00);
$table->unsignedDecimal('cost')->nullable()->default(0.00);
$table->unsignedInteger('capacity')->nullable()->default(0);
$table->string('notes')->nullable();
$table->boolean('active')->default(true);

View File

@@ -14,11 +14,11 @@ class CreateAirportsTable extends Migration
$table->string('name', 100);
$table->string('location', 100)->nullable();
$table->string('country', 64)->nullable();
$table->string('tz', 64)->nullable();
$table->string('timezone', 64)->nullable();
$table->boolean('hub')->default(false);
$table->unsignedDecimal('fuel_100ll_cost', 8)->nullable()->default(0);
$table->unsignedDecimal('fuel_jeta_cost', 8)->nullable()->default(0);
$table->unsignedDecimal('fuel_mogas_cost', 8)->nullable()->default(0);
$table->unsignedDecimal('fuel_100ll_cost')->nullable()->default(0);
$table->unsignedDecimal('fuel_jeta_cost')->nullable()->default(0);
$table->unsignedDecimal('fuel_mogas_cost')->nullable()->default(0);
$table->float('lat', 7, 4)->nullable()->default(0.0);
$table->float('lon', 7, 4)->nullable()->default(0.0);
});

View File

@@ -1,7 +1,6 @@
<?php
use App\Models\Enums\FlightType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
@@ -16,7 +15,7 @@ class CreateFlightTables extends Migration
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->string('id', 12);
$table->string('id', \App\Models\Flight::ID_MAX_LENGTH);
$table->unsignedInteger('airline_id');
$table->string('flight_number', 10);
$table->string('route_code', 5)->nullable();
@@ -27,8 +26,8 @@ class CreateFlightTables extends Migration
$table->string('dpt_time', 10)->nullable();
$table->string('arr_time', 10)->nullable();
$table->unsignedInteger('level')->nullable()->default(0);
$table->unsignedDecimal('distance', 19)->nullable()->default(0.0);
$table->unsignedDecimal('flight_time', 19)->nullable();
$table->unsignedDecimal('distance')->nullable()->default(0.0);
$table->unsignedInteger('flight_time')->nullable();
$table->tinyInteger('flight_type')->default(FlightType::PASSENGER);
$table->text('route')->nullable();
$table->text('notes')->nullable();
@@ -38,15 +37,13 @@ class CreateFlightTables extends Migration
$table->primary('id');
#$table->unique('flight_number');
$table->index('flight_number');
$table->index('dpt_airport_id');
$table->index('arr_airport_id');
});
Schema::create('flight_fare', function (Blueprint $table) {
$table->string('flight_id', 12);
$table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH);
$table->unsignedInteger('fare_id');
$table->string('price', 10)->nullable();
$table->string('cost', 10)->nullable();
@@ -58,7 +55,7 @@ class CreateFlightTables extends Migration
Schema::create('flight_fields', function (Blueprint $table) {
$table->increments('id');
$table->string('flight_id', 12);
$table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH);
$table->string('name', 50);
$table->text('value');
$table->timestamps();

View File

@@ -19,16 +19,16 @@ class CreateSubfleetTables extends Migration
$table->string('name', 50);
$table->string('type', 50);
$table->unsignedTinyInteger('fuel_type')->nullable();
$table->unsignedDecimal('cargo_capacity', 19)->nullable();
$table->unsignedDecimal('fuel_capacity', 19)->nullable();
$table->unsignedDecimal('gross_weight', 19)->nullable();
$table->unsignedDecimal('cargo_capacity')->nullable();
$table->unsignedDecimal('fuel_capacity')->nullable();
$table->unsignedDecimal('gross_weight')->nullable();
$table->timestamps();
});
Schema::create('subfleet_expenses', function(Blueprint $table) {
$table->unsignedBigInteger('subfleet_id');
$table->string('name', 50);
$table->unsignedDecimal('cost', 19);
$table->unsignedDecimal('cost');
$table->primary(['subfleet_id', 'name']);
});
@@ -36,8 +36,8 @@ class CreateSubfleetTables extends Migration
Schema::create('subfleet_fare', function (Blueprint $table) {
$table->unsignedInteger('subfleet_id');
$table->unsignedInteger('fare_id');
$table->unsignedDecimal('price', 19)->nullable();
$table->unsignedDecimal('cost', 19)->nullable();
$table->unsignedDecimal('price')->nullable();
$table->unsignedDecimal('cost')->nullable();
$table->unsignedInteger('capacity')->nullable();
$table->timestamps();
@@ -56,8 +56,8 @@ class CreateSubfleetTables extends Migration
Schema::create('subfleet_rank', function(Blueprint $table) {
$table->unsignedInteger('rank_id');
$table->unsignedInteger('subfleet_id');
$table->unsignedDecimal('acars_pay', 19)->nullable();
$table->unsignedDecimal('manual_pay', 19)->nullable();
$table->unsignedDecimal('acars_pay')->nullable();
$table->unsignedDecimal('manual_pay')->nullable();
$table->primary(['rank_id', 'subfleet_id']);
$table->index(['subfleet_id', 'rank_id']);

View File

@@ -3,7 +3,6 @@
use App\Models\Enums\FlightType;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
@@ -18,11 +17,11 @@ class CreatePirepTables extends Migration
public function up()
{
Schema::create('pireps', function (Blueprint $table) {
$table->string('id', 12);
$table->string('id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->unsignedInteger('user_id');
$table->unsignedInteger('airline_id');
$table->unsignedInteger('aircraft_id')->nullable();
$table->string('flight_id', 12)->nullable();
$table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH)->nullable();
$table->string('flight_number', 10)->nullable();
$table->string('route_code', 5)->nullable();
$table->string('route_leg', 5)->nullable();
@@ -31,12 +30,12 @@ class CreatePirepTables extends Migration
$table->unsignedInteger('level')->nullable();
$table->unsignedDecimal('distance')->nullable();
$table->unsignedDecimal('planned_distance')->nullable();
$table->unsignedDecimal('flight_time', 19)->nullable();
$table->unsignedDecimal('planned_flight_time', 19)->nullable();
$table->unsignedDecimal('zfw', 19)->nullable();
$table->unsignedDecimal('block_fuel', 19)->nullable();
$table->unsignedDecimal('fuel_used', 19)->nullable();
$table->decimal('landing_rate', 8)->nullable();
$table->unsignedInteger('flight_time')->nullable();
$table->unsignedInteger('planned_flight_time')->nullable();
$table->unsignedDecimal('zfw')->nullable();
$table->unsignedDecimal('block_fuel')->nullable();
$table->unsignedDecimal('fuel_used')->nullable();
$table->decimal('landing_rate')->nullable();
$table->text('route')->nullable();
$table->text('notes')->nullable();
$table->unsignedTinyInteger('source')->nullable()->default(0);
@@ -44,7 +43,6 @@ class CreatePirepTables extends Migration
$table->tinyInteger('flight_type')->default(FlightType::PASSENGER);
$table->tinyInteger('state')->default(PirepState::PENDING);
$table->tinyInteger('status')->default(PirepStatus::SCHEDULED);
$table->longText('raw_data')->nullable();
$table->timestamps();
$table->primary('id');
@@ -56,7 +54,7 @@ class CreatePirepTables extends Migration
Schema::create('pirep_comments', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->unsignedInteger('user_id');
$table->text('comment');
$table->timestamps();
@@ -67,16 +65,16 @@ class CreatePirepTables extends Migration
*/
Schema::create('pirep_expenses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->string('name');
$table->double('value', 19, 2)->nullable();
$table->double('value')->nullable();
$table->index('pirep_id');
});
Schema::create('pirep_fares', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->unsignedBigInteger('fare_id');
$table->unsignedInteger('count')->nullable();
@@ -95,7 +93,7 @@ class CreatePirepTables extends Migration
Schema::create('pirep_field_values', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->string('name', 50);
$table->string('value')->nullable();
$table->string('source')->nullable();

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBidsTable extends Migration
{
@@ -16,7 +16,7 @@ class CreateBidsTable extends Migration
Schema::create('user_bids', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('flight_id', 12);
$table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH);
$table->timestamps();
$table->index('user_id');

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNavdataTables extends Migration
{

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAcarsTables extends Migration
{
@@ -15,7 +15,7 @@ class CreateAcarsTables extends Migration
{
Schema::create('acars', function (Blueprint $table) {
$table->string('id', 12);
$table->string('pirep_id', 12);
$table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH);
$table->unsignedTinyInteger('type');
$table->unsignedInteger('nav_type')->nullable();
$table->unsignedInteger('order')->default(0);

View File

@@ -23,13 +23,10 @@ class CreateStatsTable extends Migration
$table->timestamps();
});
$this->addCounterGroups([
/*$this->addCounterGroups([
'flights' => 1,
]);
/**
* Initial default settings
*/
$stats = [
[
'id' => $this->formatSettingId('flights.total_flights'),
@@ -47,7 +44,7 @@ class CreateStatsTable extends Migration
],
];
$this->addData('stats', $stats);
$this->addData('stats', $stats);*/
}
/**

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNewsTable extends Migration
{

View File

@@ -0,0 +1,543 @@
acars:
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: TNV
lat: 30.28852
lon: -96.058239
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: IAH
lat: 29.95691
lon: -95.345719
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: LCH
lat: 30.14151
lon: -93.105569
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: MEI
lat: 32.37843
lon: -88.804267
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: ATL
lat: 33.62907
lon: -84.435064
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: SIE
lat: 39.0955
lon: -74.800344
created_at: now
updated_at: now
- id: 7e5Q5wlxBpxe
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4314'
lon: '28.1399'
heading: '251'
altitude: '1040'
vs: '-950'
gs: '62'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:06:36'
updated_at: '2018-02-21 20:06:36'
- id: 9aAN5XQ7y6Ob
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4169'
lon: '28.1202'
heading: '238'
altitude: '350'
vs: '-200'
gs: '58'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:08:06'
updated_at: '2018-02-21 20:08:06'
- id: aADPEZ6kR81e
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Brakes are Released'
lat: '36.4004'
lon: '28.0689'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:02:47'
updated_at: '2018-02-21 20:02:47'
- id: aOYypxgnx1Nd
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Brakes are On'
lat: '36.4004'
lon: '28.0689'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:02:37'
updated_at: '2018-02-21 20:02:37'
- id: azpKgO7O4r2d
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4097'
lon: '28.1016'
heading: '255'
altitude: '120'
vs: '-250'
gs: '61'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:09:06'
updated_at: '2018-02-21 20:09:06'
- id: b826rZMqoKLe
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4159'
lon: '28.1218'
heading: '70'
altitude: '1370'
vs: '700'
gs: '92'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:05:06'
updated_at: '2018-02-21 20:05:06'
- id: bDk9KjqgQxka
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4010'
lon: '28.0711'
heading: '70'
altitude: '20'
vs: '0'
gs: '52'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:06'
updated_at: '2018-02-21 20:03:06'
- id: bmZQWxqo2D0d
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Airborne and Beacons are off'
lat: '36.4018'
lon: '28.0739'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:15'
updated_at: '2018-02-21 20:03:15'
- id: bo2QWzjqBg3a
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: "Landed @ 59 Knots with -90 Vertical Speed With a heading of 251 and with 1.2416 G Force\nArrival Weather: KJFK 211951Z 19007KT 10SM FEW033 FEW070 FEW270 18/12 A3022 RMK AO2 SLP233 T01780122"
lat: '36.4075'
lon: '28.0929'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:09:33'
updated_at: '2018-02-21 20:09:33'
- id: bqxYWBQ0yrpa
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Engine 1 Started'
lat: '36.4004'
lon: '28.0689'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:02:38'
updated_at: '2018-02-21 20:02:38'
- id: bW67AJQwJRWa
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Flaps 3 Selected at 1360ft and 101kts'
lat: '36.4287'
lon: '28.1486'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:06:10'
updated_at: '2018-02-21 20:06:10'
- id: bYEvDL73AmMb
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4042'
lon: '28.0820'
heading: '70'
altitude: '200'
vs: '-50'
gs: '78'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:36'
updated_at: '2018-02-21 20:03:36'
- id: dG65NmMk1N8b
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4124'
lon: '28.1113'
heading: '241'
altitude: '230'
vs: '-250'
gs: '62'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:08:36'
updated_at: '2018-02-21 20:08:36'
- id: dNk9owOZwGLe
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4117'
lon: '28.1075'
heading: '70'
altitude: '990'
vs: '650'
gs: '88'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:04:36'
updated_at: '2018-02-21 20:04:36'
- id: dR6ovAlxj1Ed
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Airborne and Navigation Lights are off'
lat: '36.4020'
lon: '28.0744'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:16'
updated_at: '2018-02-21 20:03:16'
- id: e73LqZ9Z87we
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Flaps 2 Selected at 20ft and 0kts'
lat: '36.4004'
lon: '28.0689'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:02:48'
updated_at: '2018-02-21 20:02:48'
- id: e9rQvZ9095Da
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Flaps 0 Selected at 190ft and 69kts'
lat: '36.4037'
lon: '28.0802'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:32'
updated_at: '2018-02-21 20:03:32'
- id: egJLWonpgwZd
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4203'
lon: '28.1366'
heading: '70'
altitude: '1500'
vs: '-150'
gs: '97'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:05:36'
updated_at: '2018-02-21 20:05:36'
- id: egJLWonx6p3d
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4274'
lon: '28.1487'
heading: '6'
altitude: '1390'
vs: '-450'
gs: '102'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:06:06'
updated_at: '2018-02-21 20:06:06'
- id: egJLWopjvKDd
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Beacon lights are off and engine is started'
lat: '36.4004'
lon: '28.0689'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:02:39'
updated_at: '2018-02-21 20:02:39'
- id: ejRqWrYE8Nye
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4080'
lon: '28.0949'
heading: '70'
altitude: '640'
vs: '400'
gs: '81'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:04:06'
updated_at: '2018-02-21 20:04:06'
- id: erkRWD2wROBa
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: "Took off @ 68 Knots and Flaps at Position 2 With a heading of 70 Degrees \nDeparture Weather KAUS 211953Z 35018KT 2SM R17L/3500VP6000FT -RA BR OVC010 05/05 A3017 RMK AO2 SFC VIS 2 1/2 SLP216"
lat: '36.4018'
lon: '28.0736'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:14'
updated_at: '2018-02-21 20:03:14'
- id: erkRWDmNz92a
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4216'
lon: '28.1277'
heading: '210'
altitude: '440'
vs: '-250'
gs: '55'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:07:36'
updated_at: '2018-02-21 20:07:36'
- id: kazvG4B4z0Oa
pirep_id: pirepid_2
type: '2'
nav_type: ''
order: '0'
name: ''
log: 'Landing light OFF Below FL100'
lat: '36.4022'
lon: '28.0750'
heading: ''
altitude: ''
vs: ''
gs: ''
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:03:17'
updated_at: '2018-02-21 20:03:17'
- id: wdL7o1YlAZjb
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4263'
lon: '28.1347'
heading: '183'
altitude: '660'
vs: '-500'
gs: '56'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:07:06'
updated_at: '2018-02-21 20:07:06'
- id: zbq7vpVrwB2e
pirep_id: pirepid_2
type: '0'
nav_type: ''
order: '0'
name: ''
log: ''
lat: '36.4072'
lon: '28.0917'
heading: '252'
altitude: '20'
vs: '0'
gs: '58'
transponder: ''
autopilot: ''
fuel_flow: ''
sim_time: ''
created_at: '2018-02-21 20:09:36'
updated_at: '2018-02-21 20:09:36'

View File

@@ -10,7 +10,7 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago

View File

@@ -10,7 +10,7 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago

View File

@@ -4,6 +4,7 @@ airlines:
icao: VMS
iata: VM
name: phpvms airlines
country: us
active: 1
created_at: now
updated_at: now
@@ -110,91 +111,96 @@ airports:
name: Austin-Bergstrom
location: Austin, Texas, USA
country: United States
timezone: America/Chicago
lat: 30.1945278
lon: -97.6698889
hub: 1
tz: America/Chicago
- id: KJFK
iata: JFK
icao: KJFK
name: John F Kennedy
location: New York, New York, USA
country: United States
timezone: America/New_York
lat: 40.6399257
lon: -73.7786950
hub: 1
tz: America/New_York
- id: KBWI
iata: BWI
icao: KBWI
name: Baltimore/Washington International Thurgood Marshall Airport
location: Baltimore, MD
country: United States
timezone: America/New_York
lat: 39.1754
lon: -76.6683
tz: America/New_York
- id: KIAH
iata: IAH
icao: KIAH
name: George Bush Intercontinental Houston Airport
location: Houston, TX
country: United States
timezone: America/Chicago
lat: 29.9844
lon: -95.3414
tz: America/Chicago
- id: KORD
iata: ORD
icao: KORD
name: Chicago O'Hare International Airport
location: Chicago, IL
country: United States
timezone: America/Chicago
lat: 41.9786
lon: -87.9048
tz: America/Chicago
- id: KDFW
iata: DFW
icao: KDFW
name: Dallas Fort Worth International Airport
location: Dallas, TX
country: United States
timezone: America/Chicago
lat: 32.8968
lon: -97.038
tz: America/Chicago
- id: EFHK
iata: HEL
icao: EFHK
name: Helsinki Vantaa Airport
location: Helsinki
country: Finland
timezone: Europe/Helsinki
lat: 60.3172
lon: 24.9633
tz: Europe/Helsinki
- id: EGLL
iata: LHR
icao: EGLL
name: London Heathrow
location: London, England
timezone: Europe/London
lat: 51.4775
lon: -0.4614
tz: Europe/London
- id: LGRP
iata: RHO
icao: LGRP
name: Diagoras Airport
location: Rhodos
country: Greece
timezone: Europe/Athens
lat: 36.4054
lon: 28.0862
#
aircraft:
- id: 1
subfleet_id: 1
name: Boeing 747-400
registration: NC17
tail_number: 17
registration: 001Z
- id: 2
subfleet_id: 2
name: Boeing 777-200
registration: NC20
tail_number: 20
registration: C202
- id: 3
subfleet_id: 1
name: Boeing 747-412
registration: NS233
tail_number: 1233
registration: S2333
fares:
- id: 1
@@ -271,8 +277,8 @@ flights:
airline_id: 1
flight_number: 6028
route_code: A
dpt_airport_id: KIAH
arr_airport_id: KAUS
dpt_airport_id: LGRP
arr_airport_id: LGRP
dpt_time: 9AM CST
arr_time: 1030AM CST
route: PITZZ4 MNURE WLEEE4
@@ -309,56 +315,6 @@ user_bids:
user_id: 1
flight_id: flightid_3
acars:
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: TNV
lat: 30.28852
lon: -96.058239
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: IAH
lat: 29.95691
lon: -95.345719
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: LCH
lat: 30.14151
lon: -93.105569
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: MEI
lat: 32.37843
lon: -88.804267
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: ATL
lat: 33.62907
lon: -84.435064
created_at: now
updated_at: now
- pirep_id: pirepid_1
type: 1
nav_type: 2
name: SIE
lat: 39.0955
lon: -74.800344
created_at: now
updated_at: now
pireps:
- id: pirepid_1
user_id: 1
@@ -380,12 +336,14 @@ pireps:
flight_id: flightid_2
flight_number: 101
aircraft_id: 1
dpt_airport_id: KJFK
arr_airport_id: KAUS
dpt_airport_id: LGRP
arr_airport_id: LGRP
flight_time: 180 # 6 hours
state: 1
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
notes: just a pilot report
source: 1
source_name: sample
created_at: NOW
updated_at: NOW
- id: pirepid_3

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PirepAccepted
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PirepFiled
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PirepRejected
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class TestEvent
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserAccepted
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserRegistered
{

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Event triggered when a user's state changes

View File

@@ -3,9 +3,9 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserStatsChanged
{

View File

@@ -0,0 +1,20 @@
<?php
/**
*
*/
namespace App\Exceptions;
use Symfony\Component\HttpKernel\Exception\HttpException;
class AircraftPermissionDenied extends HttpException
{
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(
400,
'User is not allowed to fly this aircraft',
$previous, $headers, $code
);
}
}

View File

@@ -0,0 +1,20 @@
<?php
/**
*
*/
namespace App\Exceptions;
use Symfony\Component\HttpKernel\Exception\HttpException;
class BidExists extends HttpException
{
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(
409,
'A bid already exists for this flight',
$previous, $headers, $code
);
}
}

View File

@@ -2,19 +2,23 @@
namespace App\Exceptions;
use \Illuminate\Validation\ValidationException;
use Log;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Log;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Handler
* @package App\Exceptions
*/
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
@@ -37,66 +41,82 @@ class Handler extends ExceptionHandler
parent::report($exception);
}
/**
* Create an error message
* @param $status_code
* @param $message
* @return array
*/
protected function createError($status_code, $message)
{
return [
'error' => [
'status' => $status_code,
'message' => $message,
]
];
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
* @return mixed
*/
public function render($request, Exception $exception)
{
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException
&& $exception->getStatusCode() == 403) {
return redirect()->guest('login');
}
if ($request->expectsJson() || $request->is('api/*')) {
if($request->is('api/*')) {
$headers = [];
$error = [
'error' => [
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]
];
Log::error('API Error', $exception->getTrace());
$status = 400;
$http_code = $exception->getCode();
Log::error($exception->getMessage());
if ($this->isHttpException($exception)) {
$status = $exception->getStatusCode();
$http_code = $exception->getStatusCode();
if($exception instanceof ModelNotFoundException ||
$exception instanceof NotFoundHttpException) {
$error = $this->createError(404, $exception->getMessage());
}
if($exception instanceof ModelNotFoundException) {
$status = 404;
$http_code = 404;
# Custom exceptions should be extending HttpException
elseif ($exception instanceof HttpException) {
$error = $this->createError(
$exception->getStatusCode(),
$exception->getMessage()
);
$headers = $exception->getHeaders();
}
if($exception instanceof ValidationException) {
$status = 400;
$http_code = 400;
$errors = $exception->errors();
# Create the detailed errors from the validation errors
elseif($exception instanceof ValidationException) {
$error_messages = [];
$errors = $exception->errors();
foreach($errors as $field => $error) {
$error_messages[] = implode(', ', $error);
}
$error['error']['message'] = implode(', ', $error_messages);
$message = implode(', ', $error_messages);
$error = $this->createError(400, $message);
$error['error']['errors'] = $errors;
Log::error('Validation errors', $errors);
}
else {
$error = $this->createError(400, $exception->getMessage());
}
# Only add trace if in dev
if(config('app.env') === 'dev') {
$error['error']['trace'] = $exception->getTrace()[0];
}
$error['error']['http_code'] = $http_code;
return response()->json($error, $status);
return response()->json($error, $error['error']['status'], $headers);
}
if ($exception instanceof HttpException
&& $exception->getStatusCode() === 403) {
return redirect()->guest('login');
}
return parent::render($request, $exception);
@@ -111,8 +131,9 @@ class Handler extends ExceptionHandler
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
if ($request->expectsJson() || $request->is('api/*')) {
$error = $this->createError(401, 'Unauthenticated');
return response()->json($error, 401);
}
return redirect()->guest('login');
@@ -120,8 +141,10 @@ class Handler extends ExceptionHandler
/**
* Render the given HttpException.
* @param HttpException $e
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(\Symfony\Component\HttpKernel\Exception\HttpException $e)
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
view()->replaceNamespace('errors', [
@@ -130,11 +153,12 @@ class Handler extends ExceptionHandler
__DIR__ . '/views',
]);
#Log::info('error status '. $status);
if (view()->exists("errors::{$status}")) {
#if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) {
return response()->view("errors::{$status}", ['exception' => $e], $status, $e->getHeaders());
return response()->view("errors::{$status}", [
'exception' => $e,
'SKIN_NAME' => config('phpvms.skin'),
], $status, $e->getHeaders());
} else {
return $this->convertExceptionToResponse($e);
}

View File

@@ -0,0 +1,20 @@
<?php
/**
*
*/
namespace App\Exceptions;
use Symfony\Component\HttpKernel\Exception\HttpException;
class PirepCancelled extends HttpException
{
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(
400,
'PIREP has been cancelled, updates are not allowed',
$previous, $headers, $code
);
}
}

View File

@@ -5,8 +5,9 @@
namespace App\Exceptions;
use Symfony\Component\HttpKernel\Exception\HttpException;
class SettingNotFound extends \Exception
class SettingNotFound extends HttpException
{
}

View File

@@ -3,7 +3,7 @@
namespace App\Facades;
use GuzzleHttp\Client;
use \Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Facade;
class Utils extends Facade
{

View File

@@ -2,12 +2,12 @@
namespace App\Http\Controllers\Admin;
use App\Models\Subfleet;
use App\Http\Requests\CreateAircraftRequest;
use App\Http\Requests\UpdateAircraftRequest;
use App\Models\Subfleet;
use App\Repositories\AircraftRepository;
use Illuminate\Http\Request;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
@@ -15,6 +15,10 @@ class AircraftController extends BaseController
{
private $aircraftRepository;
/**
* AircraftController constructor.
* @param AircraftRepository $aircraftRepo
*/
public function __construct(
AircraftRepository $aircraftRepo
) {
@@ -51,11 +55,14 @@ class AircraftController extends BaseController
*/
public function store(CreateAircraftRequest $request)
{
$input = $request->all();
$this->aircraftRepository->create($input);
$attrs = $request->all();
$attrs['active'] = get_truth_state($attrs['active']);
$aircraft = $this->aircraftRepository->create($attrs);
Flash::success('Aircraft saved successfully.');
return redirect(route('admin.aircraft.index'));
return redirect(route('admin.aircraft.edit', ['id' => $aircraft->id]));
}
/**
@@ -106,7 +113,10 @@ class AircraftController extends BaseController
return redirect(route('admin.aircraft.index'));
}
$this->aircraftRepository->update($request->all(), $id);
$attrs = $request->all();
$attrs['active'] = get_truth_state($attrs['active']);
$this->aircraftRepository->update($attrs, $id);
Flash::success('Aircraft updated successfully.');
return redirect(route('admin.aircraft.index'));

View File

@@ -2,27 +2,33 @@
namespace App\Http\Controllers\Admin;
use Flash;
use Response;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Http\Requests\CreateAirlineRequest;
use App\Http\Requests\UpdateAirlineRequest;
use App\Repositories\AirlineRepository;
use App\Support\Countries;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class AirlinesController extends BaseController
{
/** @var AirlineRepository */
private $airlineRepo;
public function __construct(AirlineRepository $airlinesRepo)
{
/**
* AirlinesController constructor.
* @param AirlineRepository $airlinesRepo
*/
public function __construct(
AirlineRepository $airlinesRepo
) {
$this->airlineRepo = $airlinesRepo;
}
/**
* Display a listing of the Airlines.
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function index(Request $request)
{
@@ -38,7 +44,9 @@ class AirlinesController extends BaseController
*/
public function create()
{
return view('admin.airlines.create');
return view('admin.airlines.create', [
'countries' => Countries::getSelectList(),
]);
}
/**
@@ -50,15 +58,12 @@ class AirlinesController extends BaseController
$airlines = $this->airlineRepo->create($input);
Flash::success('Airlines saved successfully.');
return redirect(route('admin.airlines.index'));
}
/**
* Display the specified Airlines.
*
* @param int $id
*
* @return mixed
*/
public function show($id)
@@ -70,14 +75,14 @@ class AirlinesController extends BaseController
return redirect(route('admin.airlines.index'));
}
return view('admin.airlines.show')->with('airlines', $airlines);
return view('admin.airlines.show', [
'airlines' => $airlines,
]);
}
/**
* Show the form for editing the specified Airlines.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -89,16 +94,18 @@ class AirlinesController extends BaseController
return redirect(route('admin.airlines.index'));
}
return view('admin.airlines.edit')->with('airline', $airline);
return view('admin.airlines.edit', [
'airline' => $airline,
'countries' => Countries::getSelectList(),
]);
}
/**
* Update the specified Airlines in storage.
*
* @param int $id
* @param int $id
* @param UpdateAirlineRequest $request
*
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateAirlineRequest $request)
{
@@ -118,9 +125,7 @@ class AirlinesController extends BaseController
/**
* Remove the specified Airlines from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -135,7 +140,6 @@ class AirlinesController extends BaseController
$this->airlineRepo->delete($id);
Flash::success('Airlines deleted successfully.');
return redirect(route('admin.airlines.index'));
}
}

View File

@@ -2,12 +2,11 @@
namespace App\Http\Controllers\Admin;
use Log;
use Flash;
use App\Http\Requests\CreateAirportRequest;
use App\Http\Requests\UpdateAirportRequest;
use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria;
use Flash;
use Illuminate\Http\Request;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Response;
@@ -18,14 +17,18 @@ class AirportController extends BaseController
/** @var AirportRepository */
private $airportRepository;
public function __construct(AirportRepository $airportRepo)
{
/**
* AirportController constructor.
* @param AirportRepository $airportRepo
*/
public function __construct(
AirportRepository $airportRepo
) {
$this->airportRepository = $airportRepo;
}
/**
* Display a listing of the Airport.
*
* @param Request $request
* @return Response
* @throws \Prettus\Repository\Exceptions\RepositoryException
@@ -47,7 +50,6 @@ class AirportController extends BaseController
/**
* Show the form for creating a new Airport.
*
* @return Response
*/
public function create()
@@ -158,6 +160,11 @@ class AirportController extends BaseController
return redirect(route('admin.airports.index'));
}
/**
* Set fuel prices for this airport
* @param Request $request
* @return mixed
*/
public function fuel(Request $request)
{
$id = $request->id;

View File

@@ -2,22 +2,27 @@
namespace App\Http\Controllers\Admin;
use Auth;
use Flash;
use Version;
use Illuminate\Http\Request;
use App\Facades\Utils;
use App\Repositories\NewsRepository;
use App\Repositories\PirepRepository;
use App\Repositories\UserRepository;
use Auth;
use Flash;
use Illuminate\Http\Request;
use Log;
use Version;
use vierbergenlars\SemVer\version as semver;
class DashboardController extends BaseController
{
private $newsRepo, $pirepRepo, $userRepo;
/**
* DashboardController constructor.
* @param NewsRepository $newsRepo
* @param PirepRepository $pirepRepo
* @param UserRepository $userRepo
*/
public function __construct(
NewsRepository $newsRepo,
PirepRepository $pirepRepo,
@@ -36,11 +41,16 @@ class DashboardController extends BaseController
*/
protected function checkNewVersion()
{
$current_version = new semver(Version::compact());
$latest_version = new semver(Utils::downloadUrl(config('phpvms.version_file')));
try {
$current_version = new semver(Version::compact());
$latest_version = new semver(Utils::downloadUrl(config('phpvms.version_file')));
if(semver::gt($latest_version, $current_version)) {
Flash::warning('New version '.$latest_version.' is available!');
if (semver::gt($latest_version, $current_version)) {
Flash::warning('New version ' . $latest_version . ' is available!');
}
} catch (\Exception $e) {
Log::error($e->getMessage());
Flash::warning('Could not contact phpVMS for version check');
}
}

View File

@@ -5,8 +5,8 @@ namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreateFareRequest;
use App\Http\Requests\UpdateFareRequest;
use App\Repositories\FareRepository;
use Illuminate\Http\Request;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
@@ -15,17 +15,21 @@ class FareController extends BaseController
/** @var FareRepository */
private $fareRepository;
public function __construct(FareRepository $fareRepo)
{
/**
* FareController constructor.
* @param FareRepository $fareRepo
*/
public function __construct(
FareRepository $fareRepo
) {
$this->fareRepository = $fareRepo;
}
/**
* Display a listing of the Fare.
*
* @param Request $request
*
* @return Response
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function index(Request $request)
{
@@ -48,10 +52,9 @@ class FareController extends BaseController
/**
* Store a newly created Fare in storage.
*
* @param CreateFareRequest $request
*
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function store(CreateFareRequest $request)
{
@@ -64,9 +67,7 @@ class FareController extends BaseController
/**
* Display the specified Fare.
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -82,9 +83,7 @@ class FareController extends BaseController
/**
* Show the form for editing the specified Fare.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -100,11 +99,10 @@ class FareController extends BaseController
/**
* Update the specified Fare in storage.
*
* @param int $id
* @param int $id
* @param UpdateFareRequest $request
*
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateFareRequest $request)
{
@@ -122,9 +120,7 @@ class FareController extends BaseController
/**
* Remove the specified Fare from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)

View File

@@ -2,22 +2,21 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreateFlightRequest;
use App\Http\Requests\UpdateFlightRequest;
use App\Models\Enums\FlightType;
use App\Models\Flight;
use App\Models\FlightFields;
use App\Http\Requests\CreateFlightRequest;
use App\Http\Requests\UpdateFlightRequest;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\FareRepository;
use App\Repositories\FlightRepository;
use App\Repositories\SubfleetRepository;
use App\Services\FareService;
use App\Services\FlightService;
use Illuminate\Http\Request;
use App\Support\Units\Time;
use Flash;
use Illuminate\Http\Request;
use Response;
class FlightController extends BaseController
@@ -30,6 +29,16 @@ class FlightController extends BaseController
$flightSvc,
$subfleetRepo;
/**
* FlightController constructor.
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param FareRepository $fareRepo
* @param FlightRepository $flightRepo
* @param FareService $fareSvc
* @param FlightService $flightSvc
* @param SubfleetRepository $subfleetRepo
*/
public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
@@ -48,6 +57,10 @@ class FlightController extends BaseController
$this->subfleetRepo = $subfleetRepo;
}
/**
* @param $flight
* @return array
*/
protected function getAvailSubfleets($flight)
{
$retval = [];
@@ -80,7 +93,6 @@ class FlightController extends BaseController
/**
* Show the form for creating a new Flight.
*
* @return Response
*/
public function create()
@@ -121,7 +133,11 @@ class FlightController extends BaseController
return redirect()->back()->withInput($request->all());
}
$input['active'] = get_truth_state($input['active']);;
$input['active'] = get_truth_state($input['active']);
$time = new Time($input['minutes'], $input['hours']);
$input['flight_time'] = $time->getMinutes();
$flight = $this->flightRepo->create($input);
Flash::success('Flight saved successfully.');
@@ -130,7 +146,7 @@ class FlightController extends BaseController
/**
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return mixed
*/
public function show($id)
{
@@ -150,17 +166,20 @@ class FlightController extends BaseController
/**
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return mixed
*/
public function edit($id)
{
$flight = $this->flightRepo->findWithoutFail($id);
if (empty($flight)) {
Flash::error('Flight not found');
return redirect(route('admin.flights.index'));
}
$time = new Time($flight->flight_time);
$flight->hours = $time->hours;
$flight->minutes = $time->minutes;
$avail_subfleets = $this->getAvailSubfleets($flight);
return view('admin.flights.edit', [
'flight' => $flight,
@@ -209,7 +228,12 @@ class FlightController extends BaseController
return redirect()->back()->withInput($request->all());
}
$input['flight_time'] = Time::init(
$input['minutes'],
$input['hours'])->getMinutes();
$input['active'] = get_truth_state($input['active']);
$this->flightRepo->update($input, $id);
Flash::success('Flight updated successfully.');
@@ -238,7 +262,7 @@ class FlightController extends BaseController
/**
* @param $flight
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return mixed
*/
protected function return_fields_view($flight)
{
@@ -250,7 +274,7 @@ class FlightController extends BaseController
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return mixed
*/
public function fields(Request $request)
{
@@ -302,7 +326,7 @@ class FlightController extends BaseController
/**
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return mixed
*/
public function subfleets($id, Request $request)
{

View File

@@ -2,29 +2,25 @@
namespace App\Http\Controllers\Admin;
use App\Services\UserService;
use Log;
use Flash;
use Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Services\PIREPService;
use App\Models\PirepComment;
use App\Models\Enums\PirepState;
use App\Facades\Utils;
use App\Http\Requests\CreatePirepRequest;
use App\Http\Requests\UpdatePirepRequest;
use App\Models\Enums\PirepState;
use App\Models\PirepComment;
use App\Repositories\AircraftRepository;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\PirepRepository;
use App\Repositories\SubfleetRepository;
use App\Facades\Utils;
use App\Services\PIREPService;
use App\Services\UserService;
use App\Support\Units\Time;
use Flash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Log;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class PirepController extends BaseController
@@ -37,6 +33,16 @@ class PirepController extends BaseController
$subfleetRepo,
$userSvc;
/**
* PirepController constructor.
* @param AirportRepository $airportRepo
* @param AirlineRepository $airlineRepo
* @param AircraftRepository $aircraftRepo
* @param PirepRepository $pirepRepo
* @param PIREPService $pirepSvc
* @param SubfleetRepository $subfleetRepo
* @param UserService $userSvc
*/
public function __construct(
AirportRepository $airportRepo,
AirlineRepository $airlineRepo,
@@ -141,11 +147,12 @@ class PirepController extends BaseController
*/
public function store(CreatePirepRequest $request)
{
$input = $request->all();
$pirep = $this->pirepRepo->create($input);
$attrs = $request->all();
$pirep = $this->pirepRepo->create($attrs);
$pirep->flight_time = ((int) Utils::hoursToMinutes($request['hours']))
+ ((int) $request['minutes']);
$hours = (int) $attrs['hours'];
$minutes = (int) $attrs['minutes'];
$pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes;
Flash::success('Pirep saved successfully.');
return redirect(route('admin.pireps.index'));
@@ -183,12 +190,19 @@ class PirepController extends BaseController
return redirect(route('admin.pireps.index'));
}
$hms = Utils::minutesToTimeParts($pirep->flight_time);
$pirep->hours = $hms['h'];
$pirep->minutes = $hms['m'];
$time = new Time($pirep->flight_time);
$pirep->hours = $time->hours;
$pirep->minutes = $time->minutes;
# Can we modify?
$read_only = false;
if($pirep->state !== PirepState::PENDING) {
$read_only = false;
}
return view('admin.pireps.edit', [
'pirep' => $pirep,
'read_only' => $read_only,
'aircraft' => $this->aircraftList(),
'airports' => $this->airportRepo->selectBoxList(),
'airlines' => $this->airlineRepo->selectBoxList(),
@@ -200,21 +214,27 @@ class PirepController extends BaseController
* @param UpdatePirepRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Prettus\Validator\Exceptions\ValidatorException
* @throws \Exception
*/
public function update($id, UpdatePirepRequest $request)
{
$pirep = $this->pirepRepo->findWithoutFail($id);
$pirep->flight_time = ((int) Utils::hoursToMinutes($request['hours']))
+ ((int) $request['minutes']);
if (empty($pirep)) {
Flash::error('Pirep not found');
return redirect(route('admin.pireps.index'));
}
$attrs = $request->all();
$orig_route = $pirep->route;
$orig_flight_time = $pirep->flight_time;
$attrs = $request->all();
# Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
$pirep = $this->pirepRepo->update($attrs, $id);
// A route change in the PIREP, so update the saved points in the ACARS table
@@ -257,19 +277,20 @@ class PirepController extends BaseController
$pirep = $this->pirepRepo->findWithoutFail($request->id);
if($request->isMethod('post')) {
$new_status = (int) $request->new_status;
$new_status = (int) $request->post('new_status');
$pirep = $this->pirepSvc->changeState($pirep, $new_status);
}
$pirep->refresh();
return view('admin.pireps.actions', ['pirep' => $pirep]);
return view('admin.pireps.actions', ['pirep' => $pirep, 'on_edit_page' => false]);
}
/**
* Add a comment to the Pirep
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return mixed
* @throws \Exception
*/
public function comments($id, Request $request)
{

View File

@@ -5,8 +5,8 @@ namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreatePirepFieldRequest;
use App\Http\Requests\UpdatePirepFieldRequest;
use App\Repositories\PirepFieldRepository;
use Illuminate\Http\Request;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
@@ -15,8 +15,13 @@ class PirepFieldController extends BaseController
/** @var PirepFieldRepository */
private $pirepFieldRepo;
public function __construct(PirepFieldRepository $pirepFieldRepo)
{
/**
* PirepFieldController constructor.
* @param PirepFieldRepository $pirepFieldRepo
*/
public function __construct(
PirepFieldRepository $pirepFieldRepo
){
$this->pirepFieldRepo = $pirepFieldRepo;
}
@@ -53,12 +58,13 @@ class PirepFieldController extends BaseController
*/
public function store(CreatePirepFieldRequest $request)
{
$input = $request->all();
$input['required'] = get_truth_state($input['required']);
$attrs = $request->all();
$attrs['slug'] = str_slug($attrs['name']);
$attrs['required'] = get_truth_state($attrs['required']);
$this->pirepFieldRepo->create($input);
$this->pirepFieldRepo->create($attrs);
Flash::success('PirepField saved successfully.');
Flash::success('Field added successfully.');
return redirect(route('admin.pirepfields.index'));
}
@@ -91,7 +97,7 @@ class PirepFieldController extends BaseController
$field = $this->pirepFieldRepo->findWithoutFail($id);
if (empty($field)) {
Flash::error('PirepField not found');
Flash::error('Field not found');
return redirect(route('admin.pirepfields.index'));
}
@@ -114,10 +120,11 @@ class PirepFieldController extends BaseController
}
$attrs = $request->all();
$attrs['slug'] = str_slug($attrs['name']);
$attrs['required'] = get_truth_state($attrs['required']);
$this->pirepFieldRepo->update($attrs, $id);
Flash::success('PirepField updated successfully.');
Flash::success('Field updated successfully.');
return redirect(route('admin.pirepfields.index'));
}
@@ -131,13 +138,13 @@ class PirepFieldController extends BaseController
$field = $this->pirepFieldRepo->findWithoutFail($id);
if (empty($field)) {
Flash::error('PirepField not found');
Flash::error('Field not found');
return redirect(route('admin.pirepfields.index'));
}
$this->pirepFieldRepo->delete($id);
Flash::success('PirepField deleted successfully.');
Flash::success('Field deleted successfully.');
return redirect(route('admin.pirepfields.index'));
}
}

View File

@@ -2,22 +2,26 @@
namespace App\Http\Controllers\Admin;
use Cache;
use Flash;
use Response;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Http\Requests\CreateRankRequest;
use App\Http\Requests\UpdateRankRequest;
use App\Repositories\RankRepository;
use App\Repositories\SubfleetRepository;
use Cache;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class RankController extends BaseController
{
/** @var RankRepository */
private $rankRepository, $subfleetRepo;
/**
* RankController constructor.
* @param RankRepository $rankingRepo
* @param SubfleetRepository $subfleetRepo
*/
public function __construct(
RankRepository $rankingRepo,
SubfleetRepository $subfleetRepo
@@ -26,6 +30,11 @@ class RankController extends BaseController
$this->subfleetRepo = $subfleetRepo;
}
/**
* Get the available subfleets for a rank
* @param $rank
* @return array
*/
protected function getAvailSubfleets($rank)
{
$retval = [];
@@ -41,9 +50,9 @@ class RankController extends BaseController
/**
* Display a listing of the Ranking.
*
* @param Request $request
* @return Response
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function index(Request $request)
{
@@ -69,6 +78,7 @@ class RankController extends BaseController
* Store a newly created Ranking in storage.
* @param CreateRankRequest $request
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function store(CreateRankRequest $request)
{
@@ -84,9 +94,7 @@ class RankController extends BaseController
/**
* Display the specified Ranking.
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -105,9 +113,7 @@ class RankController extends BaseController
/**
* Show the form for editing the specified Ranking.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -128,11 +134,10 @@ class RankController extends BaseController
/**
* Update the specified Ranking in storage.
*
* @param int $id
* @param int $id
* @param UpdateRankRequest $request
*
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateRankRequest $request)
{
@@ -152,9 +157,7 @@ class RankController extends BaseController
/**
* Remove the specified Ranking from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -172,6 +175,10 @@ class RankController extends BaseController
return redirect(route('admin.ranks.index'));
}
/**
* @param $rank
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_subfleet_view($rank)
{
$avail_subfleets = $this->getAvailSubfleets($rank);
@@ -181,10 +188,14 @@ class RankController extends BaseController
]);
}
public function subfleets(Request $request)
/**
* Subfleet operations on a rank
* @param $id
* @param Request $request
* @return mixed
*/
public function subfleets($id, Request $request)
{
$id = $request->id;
$rank = $this->rankRepository->findWithoutFail($id);
if (empty($rank)) {
Flash::error('Rank not found!');

View File

@@ -2,10 +2,9 @@
namespace App\Http\Controllers\Admin;
use Log;
use Illuminate\Http\Request;
use App\Models\Setting;
use Illuminate\Http\Request;
use Log;
class SettingsController extends BaseController
{
@@ -24,6 +23,8 @@ class SettingsController extends BaseController
/**
* Update the specified setting in storage.
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(Request $request)
{
@@ -41,5 +42,4 @@ class SettingsController extends BaseController
flash('Settings saved!');
return redirect('/admin/settings');
}
}

View File

@@ -2,33 +2,28 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Flash;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
use App\Models\Enums\FuelType;
use App\Models\Airline;
use App\Models\Subfleet;
use App\Http\Requests\CreateSubfleetRequest;
use App\Http\Requests\UpdateSubfleetRequest;
use App\Models\Airline;
use App\Models\Enums\FuelType;
use App\Models\Subfleet;
use App\Repositories\AircraftRepository;
use App\Repositories\FareRepository;
use App\Repositories\RankRepository;
use App\Repositories\SubfleetRepository;
use App\Services\FareService;
use Flash;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class SubfleetController extends BaseController
{
/** @var SubfleetRepository */
private $aircraftRepo, $subfleetRepo, $fareRepo, $fareSvc;
private $aircraftRepo, $rankRepo, $subfleetRepo, $fareRepo, $fareSvc;
/**
* SubfleetController constructor.
*
* @param AircraftRepository $aircraftRepo
* @param SubfleetRepository $subfleetRepo
* @param FareRepository $fareRepo
@@ -36,16 +31,35 @@ class SubfleetController extends BaseController
*/
public function __construct(
AircraftRepository $aircraftRepo,
RankRepository $rankRepo,
SubfleetRepository $subfleetRepo,
FareRepository $fareRepo,
FareService $fareSvc
) {
$this->aircraftRepo = $aircraftRepo;
$this->rankRepo = $rankRepo;
$this->subfleetRepo = $subfleetRepo;
$this->fareRepo = $fareRepo;
$this->fareSvc = $fareSvc;
}
/**
* Get the ranks that are available to the subfleet
* @param $subfleet
* @return array
*/
protected function getAvailRanks($subfleet)
{
$retval = [];
$all_ranks = $this->rankRepo->all();
$avail_ranks = $all_ranks->except($subfleet->ranks->modelKeys());
foreach ($avail_ranks as $rank) {
$retval[$rank->id] = $rank->name;
}
return $retval;
}
/**
* Get all the fares that haven't been assigned to a given subfleet
*/
@@ -82,7 +96,6 @@ class SubfleetController extends BaseController
/**
* Show the form for creating a new Subfleet.
*
* @return Response
*/
public function create()
@@ -105,7 +118,7 @@ class SubfleetController extends BaseController
$subfleet = $this->subfleetRepo->create($input);
Flash::success('Subfleet saved successfully.');
return redirect(route('admin.subfleets.index'));
return redirect(route('admin.subfleets.edit', ['id' => $subfleet->id]));
}
/**
@@ -144,10 +157,13 @@ class SubfleetController extends BaseController
}
$avail_fares = $this->getAvailFares($subfleet);
$avail_ranks = $this->getAvailRanks($subfleet);
return view('admin.subfleets.edit', [
'airlines' => Airline::all()->pluck('name', 'id'),
'fuel_types' => FuelType::labels(),
'avail_fares' => $avail_fares,
'avail_ranks' => $avail_ranks,
'subfleet' => $subfleet,
]);
}
@@ -202,6 +218,22 @@ class SubfleetController extends BaseController
return redirect(route('admin.subfleets.index'));
}
/**
* @param Subfleet $subfleet
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_ranks_view(Subfleet $subfleet)
{
$subfleet->refresh();
$avail_ranks = $this->getAvailRanks($subfleet);
return view('admin.subfleets.ranks', [
'subfleet' => $subfleet,
'avail_ranks' => $avail_ranks,
]);
}
/**
* @param Subfleet $subfleet
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
@@ -209,6 +241,7 @@ class SubfleetController extends BaseController
protected function return_fares_view(Subfleet $subfleet)
{
$subfleet->refresh();
$avail_fares = $this->getAvailFares($subfleet);
return view('admin.subfleets.fares', [
@@ -218,13 +251,46 @@ class SubfleetController extends BaseController
}
/**
* Operations for associating ranks to the subfleet
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function fares(Request $request)
public function ranks($id, Request $request)
{
$id = $request->id;
$subfleet = $this->subfleetRepo->findWithoutFail($id);
if (empty($subfleet)) {
return $this->return_ranks_view($subfleet);
}
if ($request->isMethod('get')) {
return $this->return_ranks_view($subfleet);
}
/**
* update specific rank data
*/
if ($request->isMethod('post')) {
$subfleet->ranks()->syncWithoutDetaching([$request->input('rank_id')]);
}
// dissassociate fare from teh aircraft
elseif ($request->isMethod('delete')) {
$subfleet->ranks()->detach($request->input('rank_id'));
}
$subfleet->save();
return $this->return_ranks_view($subfleet);
}
/**
* Operations on fares to the subfleet
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function fares($id, Request $request)
{
$subfleet = $this->subfleetRepo->findWithoutFail($id);
if (empty($subfleet)) {
return $this->return_fares_view($subfleet);

View File

@@ -3,28 +3,24 @@
namespace App\Http\Controllers\Admin;
use App\Facades\Utils;
use App\Models\User;
use DB;
use Hash;
use Illuminate\Support\Facades\Auth;
use Log;
use Flash;
use Prettus\Repository\Exceptions\RepositoryException;
use Response;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Illuminate\Http\Request;
use App\Http\Requests\CreateUserRequest;
use App\Http\Requests\UpdateUserRequest;
use App\Models\Airline;
use App\Models\Airport;
use App\Models\Rank;
use App\Models\Role;
use App\Models\User;
use App\Repositories\PirepRepository;
use App\Repositories\UserRepository;
use App\Services\UserService;
use App\Models\Airport;
use App\Models\Airline;
use App\Models\Rank;
use App\Models\Role;
use DB;
use Flash;
use Hash;
use Illuminate\Http\Request;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Log;
use Prettus\Repository\Exceptions\RepositoryException;
use Response;
class UserController extends BaseController
{
@@ -34,7 +30,6 @@ class UserController extends BaseController
/**
* UserController constructor.
*
* @param UserRepository $userRepo
*/
public function __construct(
@@ -47,6 +42,10 @@ class UserController extends BaseController
$this->userRepo = $userRepo;
}
/**
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
try {
@@ -82,7 +81,7 @@ class UserController extends BaseController
public function store(CreateUserRequest $request)
{
$input = $request->all();
$User = $this->userRepo->create($input);
$user = $this->userRepo->create($input);
Flash::success('User saved successfully.');
return redirect(route('admin.users.index'));
@@ -120,9 +119,7 @@ class UserController extends BaseController
/**
* Show the form for editing the specified User.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -157,11 +154,10 @@ class UserController extends BaseController
/**
* Update the specified User in storage.
*
* @param int $id
* @param int $id
* @param UpdateUserRequest $request
*
* @return Response
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateUserRequest $request)
{
@@ -199,9 +195,7 @@ class UserController extends BaseController
/**
* Remove the specified User from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -221,6 +215,9 @@ class UserController extends BaseController
/**
* Regenerate the user's API key
* @param $id
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function regen_apikey($id, Request $request)
{

View File

@@ -2,17 +2,22 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Services\GeoService;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
use App\Services\GeoService;
use Illuminate\Http\Request;
class AcarsController extends RestController
{
protected $acarsRepo, $geoSvc, $pirepRepo;
/**
* AcarsController constructor.
* @param GeoService $geoSvc
* @param AcarsRepository $acarsRepo
* @param PirepRepository $pirepRepo
*/
public function __construct(
GeoService $geoSvc,
AcarsRepository $acarsRepo,
@@ -25,6 +30,8 @@ class AcarsController extends RestController
/**
* Return all of the flights (as points) in GeoJSON format
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
@@ -35,5 +42,4 @@ class AcarsController extends RestController
'Content-type' => 'application/json'
]);
}
}

View File

@@ -2,26 +2,33 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Repositories\AirlineRepository;
use App\Http\Resources\Airline as AirlineResource;
use App\Repositories\AirlineRepository;
use Illuminate\Http\Request;
class AirlineController extends RestController
{
protected $airlineRepo;
public function __construct(AirlineRepository $airlineRepo) {
/**
* AirlineController constructor.
* @param AirlineRepository $airlineRepo
*/
public function __construct(
AirlineRepository $airlineRepo
) {
$this->airlineRepo = $airlineRepo;
}
/**
* Return all the airlines, paginated
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
$airports = $this->airlineRepo
->orderBy('name', 'asc')
->whereOrder(['active' => true], 'name', 'asc')
->paginate(50);
return AirlineResource::collection($airports);
@@ -35,7 +42,6 @@ class AirlineController extends RestController
public function get($id)
{
$id = strtoupper($id);
AirlineResource::withoutWrapping();
return new AirlineResource($this->airlineRepo->find($id));
}
}

View File

@@ -2,18 +2,21 @@
namespace App\Http\Controllers\Api;
use App\Http\Resources\Airport as AirportResource;
use App\Repositories\AirportRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use App\Repositories\AirportRepository;
use App\Http\Resources\Airport as AirportResource;
use Log;
use VaCentral\Airport as AirportLookup;
class AirportController extends RestController
{
protected $airportRepo;
/**
* AirportController constructor.
* @param AirportRepository $airportRepo
*/
public function __construct(
AirportRepository $airportRepo
) {
@@ -22,6 +25,8 @@ class AirportController extends RestController
/**
* Return all the airports, paginated
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
@@ -37,6 +42,9 @@ class AirportController extends RestController
return AirportResource::collection($airports);
}
/**
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function index_hubs()
{
$where = [
@@ -58,7 +66,6 @@ class AirportController extends RestController
public function get($id)
{
$id = strtoupper($id);
AirportResource::withoutWrapping();
return new AirportResource($this->airportRepo->find($id));
}
@@ -73,7 +80,12 @@ class AirportController extends RestController
config('cache.keys.AIRPORT_VACENTRAL_LOOKUP.key') . $id,
config('cache.keys.RANKS_PILOT_LIST.time'),
function () use ($id) {
return AirportLookup::get($id);
try {
return AirportLookup::get($id);
} catch (\VaCentral\HttpException $e) {
Log::error($e);
return [];
}
}
);

View File

@@ -2,18 +2,21 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Repositories\AircraftRepository;
use App\Repositories\SubfleetRepository;
use App\Http\Resources\Aircraft as AircraftResource;
use App\Http\Resources\Subfleet as SubfleetResource;
use App\Repositories\AircraftRepository;
use App\Repositories\SubfleetRepository;
use Illuminate\Http\Request;
class FleetController extends RestController
{
protected $aircraftRepo, $subfleetRepo;
/**
* FleetController constructor.
* @param AircraftRepository $aircraftRepo
* @param SubfleetRepository $subfleetRepo
*/
public function __construct(
AircraftRepository $aircraftRepo,
SubfleetRepository $subfleetRepo
@@ -30,7 +33,7 @@ class FleetController extends RestController
{
$subfleets = $this->subfleetRepo
->with(['aircraft', 'airline', 'fares', 'ranks'])
->paginate(50);
->paginate();
return SubfleetResource::collection($subfleets);
}
@@ -51,13 +54,11 @@ class FleetController extends RestController
$where['id'] = $id;
}
#$all_aircraft = $this->aircraftRepo->all();
$aircraft = $this->aircraftRepo
->with(['subfleet', 'subfleet.fares'])
->findWhere($where)
->first();
AircraftResource::withoutWrapping();
return new AircraftResource($aircraft);
}
}

View File

@@ -2,38 +2,75 @@
namespace App\Http\Controllers\Api;
use App\Http\Resources\Flight as FlightResource;
use App\Http\Resources\Navdata as NavdataResource;
use App\Repositories\Criteria\WhereCriteria;
use App\Repositories\FlightRepository;
use App\Services\FlightService;
use App\Services\UserService;
use Auth;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\FlightRepository;
use App\Http\Resources\Flight as FlightResource;
use Prettus\Repository\Exceptions\RepositoryException;
/**
* Class FlightController
* @package App\Http\Controllers\Api
*/
class FlightController extends RestController
{
protected $flightRepo;
protected $flightRepo, $flightSvc, $userSvc;
public function __construct(FlightRepository $flightRepo) {
/**
* FlightController constructor.
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
* @param UserService $userSvc
*/
public function __construct(
FlightRepository $flightRepo,
FlightService $flightSvc,
UserService $userSvc
) {
$this->flightRepo = $flightRepo;
$this->flightSvc = $flightSvc;
$this->userSvc = $userSvc;
}
/**
* Return all the flights, paginated
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function index(Request $request)
{
$user = Auth::user();
$where = ['active' => true];
if (setting('pilots.only_flights_from_current', false)) {
$where['dpt_airport_id'] = $user->curr_airport_id;
}
$flights = $this->flightRepo
->orderBy('flight_number', 'asc')
->paginate(50);
->whereOrder($where, 'flight_number', 'asc')
->paginate();
foreach($flights as $flight) {
$this->flightSvc->filterSubfleets($user, $flight);
}
return FlightResource::collection($flights);
}
/**
* @param $id
* @return FlightResource
*/
public function get($id)
{
$flight = $this->flightRepo->find($id);
FlightResource::withoutWrapping();
$this->flightSvc->filterSubfleets(Auth::user(), $flight);
return new FlightResource($flight);
}
@@ -43,14 +80,40 @@ class FlightController extends RestController
*/
public function search(Request $request)
{
$user = Auth::user();
try {
$where = ['active' => true];
if (setting('pilots.only_flights_from_current')) {
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
}
$this->flightRepo->searchCriteria($request);
$this->flightRepo->pushCriteria(new RequestCriteria($request));
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where));
$flights = $this->flightRepo->paginate();
} catch (RepositoryException $e) {
return response($e, 503);
}
foreach ($flights as $flight) {
$this->flightSvc->filterSubfleets($user, $flight);
}
return FlightResource::collection($flights);
}
/**
* Get a flight's route
* @param $id
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function route($id, Request $request)
{
$flight = $this->flightRepo->find($id);
$route = $this->flightSvc->getRoute($flight);
return NavdataResource::collection($route);
}
}

View File

@@ -2,44 +2,42 @@
namespace App\Http\Controllers\Api;
use App\Http\Requests\Acars\EventRequest;
use App\Http\Requests\Acars\UpdateRequest;
use Auth;
use Log;
use Illuminate\Http\Request;
use App\Exceptions\AircraftPermissionDenied;
use App\Exceptions\PirepCancelled;
use App\Http\Requests\Acars\CommentRequest;
use App\Http\Requests\Acars\EventRequest;
use App\Http\Requests\Acars\FileRequest;
use App\Http\Requests\Acars\LogRequest;
use App\Http\Requests\Acars\PositionRequest;
use App\Http\Requests\Acars\PrefileRequest;
use App\Http\Requests\Acars\RouteRequest;
use App\Models\Acars;
use App\Models\Pirep;
use App\Models\PirepComment;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Services\GeoService;
use App\Services\PIREPService;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
use App\Http\Requests\Acars\UpdateRequest;
use App\Http\Resources\AcarsRoute as AcarsRouteResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Http\Resources\PirepComment as PirepCommentResource;
use App\Http\Resources\AcarsRoute as AcarsRouteResource;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use App\Models\Acars;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use App\Models\PirepComment;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
use App\Services\GeoService;
use App\Services\PIREPService;
use App\Services\UserService;
use Auth;
use Illuminate\Http\Request;
use Log;
class PirepController extends RestController
{
protected $acarsRepo,
$geoSvc,
$pirepRepo,
$pirepSvc;
$pirepSvc,
$userSvc;
/**
* PirepController constructor.
@@ -47,28 +45,31 @@ class PirepController extends RestController
* @param GeoService $geoSvc
* @param PirepRepository $pirepRepo
* @param PIREPService $pirepSvc
* @param UserService $userSvc
*/
public function __construct(
AcarsRepository $acarsRepo,
GeoService $geoSvc,
PirepRepository $pirepRepo,
PIREPService $pirepSvc
PIREPService $pirepSvc,
UserService $userSvc
) {
$this->acarsRepo = $acarsRepo;
$this->geoSvc = $geoSvc;
$this->pirepRepo = $pirepRepo;
$this->pirepSvc = $pirepSvc;
$this->userSvc = $userSvc;
}
/**
* Check if a PIREP is cancelled
* @param $pirep
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \App\Exceptions\PirepCancelled
*/
protected function checkCancelled(Pirep $pirep)
{
if (!$pirep->allowedUpdates()) {
throw new BadRequestHttpException('PIREP has been cancelled, comments can\'t be posted');
throw new PirepCancelled();
}
}
@@ -78,10 +79,31 @@ class PirepController extends RestController
*/
public function get($id)
{
PirepResource::withoutWrapping();
return new PirepResource($this->pirepRepo->find($id));
}
/**
* @param $pirep
* @param Request $request
*/
protected function updateFields($pirep, Request $request)
{
if (!$request->filled('fields')) {
return;
}
$pirep_fields = [];
foreach ($request->input('fields') as $field_name => $field_value) {
$pirep_fields[] = [
'name' => $field_name,
'value' => $field_value,
'source' => $pirep->source,
];
}
$this->pirepSvc->updateCustomFields($pirep->id, $pirep_fields);
}
/**
* Create a new PIREP and place it in a "inprogress" and "prefile" state
* Once ACARS updates are being processed, then it can go into an 'ENROUTE'
@@ -89,22 +111,36 @@ class PirepController extends RestController
*
* @param PrefileRequest $request
* @return PirepResource
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
*/
public function prefile(PrefileRequest $request)
{
Log::info('PIREP Prefile, user '.Auth::id(), $request->post());
$user = Auth::user();
$attrs = $request->post();
$attrs['user_id'] = Auth::id();
$attrs['user_id'] = $user->id;
$attrs['source'] = PirepSource::ACARS;
$attrs['state'] = PirepState::IN_PROGRESS;
$attrs['status'] = PirepStatus::PREFILE;
$pirep = new Pirep($attrs);
# See if this user is allowed to fly this aircraft
if(setting('pireps.restrict_aircraft_to_rank', false)) {
$can_use_ac = $this->userSvc->aircraftAllowed($user, $pirep->aircraft_id);
if (!$can_use_ac) {
throw new AircraftPermissionDenied();
}
}
# Find if there's a duplicate, if so, let's work on that
$dupe_pirep = $this->pirepSvc->findDuplicate($pirep);
if($dupe_pirep !== false) {
$pirep = $dupe_pirep;
$this->checkCancelled($pirep);
}
$pirep->save();
@@ -112,7 +148,8 @@ class PirepController extends RestController
Log::info('PIREP PREFILED');
Log::info($pirep->id);
PirepResource::withoutWrapping();
$this->updateFields($pirep, $request);
return new PirepResource($pirep);
}
@@ -124,22 +161,34 @@ class PirepController extends RestController
* @param $id
* @param UpdateRequest $request
* @return PirepResource
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateRequest $request)
{
Log::info('PIREP Update, user ' . Auth::id(), $request->post());
$user = Auth::user();
$pirep = $this->pirepRepo->find($id);
$this->checkCancelled($pirep);
$attrs = $request->post();
$attrs['user_id'] = Auth::id();
$pirep = $this->pirepRepo->update($attrs, $id);
# If aircraft is being changed, see if this user is allowed to fly this aircraft
if (array_key_exists('aircraft_id', $attrs)
&& setting('pireps.restrict_aircraft_to_rank', false)
) {
$can_use_ac = $this->userSvc->aircraftAllowed($user, $pirep->aircraft_id);
if (!$can_use_ac) {
throw new AircraftPermissionDenied();
}
}
$pirep = $this->pirepRepo->update($attrs, $id);
$this->updateFields($pirep, $request);
PirepResource::withoutWrapping();
return new PirepResource($pirep);
}
@@ -148,34 +197,53 @@ class PirepController extends RestController
* @param $id
* @param FileRequest $request
* @return PirepResource
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
* @throws \Exception
*/
public function file($id, FileRequest $request)
{
Log::info('PIREP file, user ' . Auth::id(), $request->post());
$user = Auth::user();
# Check if the status is cancelled...
$pirep = $this->pirepRepo->find($id);
$this->checkCancelled($pirep);
$attrs = $request->post();
# If aircraft is being changed, see if this user is allowed to fly this aircraft
if (array_key_exists('aircraft_id', $attrs)
&& setting('pireps.restrict_aircraft_to_rank', false)
) {
$can_use_ac = $this->userSvc->aircraftAllowed($user, $pirep->aircraft_id);
if (!$can_use_ac) {
throw new AircraftPermissionDenied();
}
}
$attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::ARRIVED;
$pirep_fields = [];
if($request->filled('fields')) {
$pirep_fields = $request->get('fields');
}
try {
$pirep = $this->pirepRepo->update($attrs, $id);
$pirep = $this->pirepSvc->create($pirep, $pirep_fields);
$pirep = $this->pirepSvc->create($pirep);
$this->updateFields($pirep, $request);
} catch (\Exception $e) {
Log::error($e);
}
PirepResource::withoutWrapping();
# See if there there is any route data posted
# If there isn't, then just write the route data from the
# route that's been posted from the PIREP
$w = ['pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE];
$count = Acars::where($w)->count(['id']);
if($count === 0) {
$this->pirepSvc->saveRoute($pirep);
}
return new PirepResource($pirep);
}
@@ -194,7 +262,6 @@ class PirepController extends RestController
'state' => PirepState::CANCELLED,
], $id);
PirepResource::withoutWrapping();
return new PirepResource($pirep);
}
@@ -215,16 +282,15 @@ class PirepController extends RestController
}
/**
* Return the GeoJSON for the ACARS line
* Return the routes for the ACARS line
* @param $id
* @param Request $request
* @return AcarsRouteResource
*/
public function acars_get($id, Request $request)
{
$pirep = $this->pirepRepo->find($id);
$this->pirepRepo->find($id);
AcarsRouteResource::withoutWrapping();
return new AcarsRouteResource(Acars::where([
'pirep_id' => $id,
'type' => AcarsType::FLIGHT_PATH
@@ -236,6 +302,7 @@ class PirepController extends RestController
* @param $id
* @param PositionRequest $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function acars_store($id, PositionRequest $request)
@@ -275,6 +342,7 @@ class PirepController extends RestController
* @param $id
* @param LogRequest $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function acars_logs($id, LogRequest $request)
@@ -306,6 +374,7 @@ class PirepController extends RestController
* @param $id
* @param EventRequest $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function acars_events($id, EventRequest $request)
@@ -349,6 +418,7 @@ class PirepController extends RestController
* @param $id
* @param CommentRequest $request
* @return PirepCommentResource
* @throws \App\Exceptions\PirepCancelled
*/
public function comments_post($id, CommentRequest $request)
{
@@ -369,14 +439,13 @@ class PirepController extends RestController
/**
* @param $id
* @param Request $request
* @return AcarsRouteResource
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function route_get($id, Request $request)
{
$this->pirepRepo->find($id);
AcarsRouteResource::withoutWrapping();
return new AcarsRouteResource(Acars::where([
return AcarsRouteResource::collection(Acars::where([
'pirep_id' => $id,
'type' => AcarsType::ROUTE
])->orderBy('order', 'asc')->get());
@@ -386,7 +455,8 @@ class PirepController extends RestController
* Post the ROUTE for a PIREP, can be done from the ACARS log
* @param $id
* @param RouteRequest $request
* @return AcarsRouteResource
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function route_post($id, RouteRequest $request)
@@ -397,6 +467,7 @@ class PirepController extends RestController
Log::info('Posting ROUTE, PIREP: '.$id, $request->post());
$count = 0;
$route = $request->post('route', []);
foreach($route as $position) {
$position['pirep_id'] = $id;
@@ -404,15 +475,18 @@ class PirepController extends RestController
$acars = Acars::create($position);
$acars->save();
++$count;
}
return $this->route_get($id, $request);
return $this->message($count . ' points added', $count);
}
/**
* @param $id
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \Exception
*/
public function route_delete($id, Request $request)
{

View File

@@ -1,10 +1,4 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: nabeelshahzad
* Date: 1/4/18
* Time: 4:20 PM
*/
namespace App\Http\Controllers\Api;

View File

@@ -2,21 +2,28 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Repositories\SettingRepository;
use App\Http\Resources\Setting as SettingResource;
use App\Repositories\SettingRepository;
use Illuminate\Http\Request;
class SettingsController extends RestController
{
protected $settingRepo;
public function __construct(SettingRepository $settingRepo) {
/**
* SettingsController constructor.
* @param SettingRepository $settingRepo
*/
public function __construct(
SettingRepository $settingRepo
) {
$this->settingRepo = $settingRepo;
}
/**
* Return all the airlines, paginated
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function index(Request $request)
{

View File

@@ -6,6 +6,9 @@ use PragmaRX\Version\Package\Facade as Version;
class StatusController extends RestController
{
/**
* @return \Illuminate\Http\JsonResponse
*/
public function status()
{
return response()->json([

View File

@@ -2,63 +2,119 @@
namespace App\Http\Controllers\Api;
use App\Http\Resources\Flight as FlightResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Http\Resources\Subfleet as SubfleetResource;
use App\Http\Resources\User as UserResource;
use App\Models\Enums\PirepState;
use App\Models\UserBid;
use App\Repositories\Criteria\WhereCriteria;
use App\Repositories\FlightRepository;
use App\Repositories\PirepRepository;
use App\Repositories\SubfleetRepository;
use App\Repositories\UserRepository;
use App\Services\FlightService;
use App\Services\UserService;
use Auth;
use Illuminate\Http\Request;
use App\Repositories\UserRepository;
use App\Models\UserBid;
use App\Http\Resources\Subfleet as SubfleetResource;
use App\Http\Resources\Flight as FlightResource;
use App\Http\Resources\User as UserResource;
use Prettus\Repository\Criteria\RequestCriteria;
use Prettus\Repository\Exceptions\RepositoryException;
class UserController extends RestController
{
protected $subfleetRepo,
protected $flightRepo,
$flightSvc,
$pirepRepo,
$subfleetRepo,
$userRepo,
$userSvc;
/**
* UserController constructor.
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
* @param PirepRepository $pirepRepo
* @param SubfleetRepository $subfleetRepo
* @param UserRepository $userRepo
* @param UserService $userSvc
*/
public function __construct(
FlightRepository $flightRepo,
FlightService $flightSvc,
PirepRepository $pirepRepo,
SubfleetRepository $subfleetRepo,
UserRepository $userRepo,
UserService $userSvc
) {
$this->flightRepo = $flightRepo;
$this->flightSvc = $flightSvc;
$this->pirepRepo = $pirepRepo;
$this->subfleetRepo = $subfleetRepo;
$this->userRepo = $userRepo;
$this->userSvc = $userSvc;
}
/**
* @param Request $request
* @return int|mixed
*/
protected function getUserId(Request $request)
{
if ($request->id === null) {
return Auth::user()->id;
}
return $request->id;
}
/**
* Return the profile for the currently auth'd user
* @param Request $request
* @return UserResource
*/
public function index(Request $request)
{
UserResource::withoutWrapping();
return new UserResource(Auth::user());
}
/**
* Get the profile for the passed-in user
* @param $id
* @return UserResource
*/
public function get($id)
{
UserResource::withoutWrapping();
return new UserResource($this->userRepo->find($id));
}
/**
* Return all of the bids for the passed-in user
* @param $id
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
* @param Request $request
* @return mixed
* @throws \App\Exceptions\BidExists
* @throws \App\Services\Exception
*/
public function bids($id)
public function bids(Request $request)
{
$flights = UserBid::where(['user_id' => $id])->get()
->pluck('flight');
$user = $this->userRepo->find($this->getUserId($request));
# Add a bid
if ($request->isMethod('PUT')) {
$flight_id = $request->input('flight_id');
$flight = $this->flightRepo->find($flight_id);
$this->flightSvc->addBid($flight, $user);
}
elseif ($request->isMethod('DELETE')) {
$flight_id = $request->input('flight_id');
$flight = $this->flightRepo->find($flight_id);
$this->flightSvc->removeBid($flight, $user);
}
# Return the flights they currently have bids on
$flights = UserBid::where(['user_id' => $user->id])
->get()->pluck('flight');
return FlightResource::collection($flights);
}
@@ -70,17 +126,37 @@ class UserController extends RestController
*/
public function fleet(Request $request)
{
if($request->id === null) {
$id = Auth::user()->id;
} else {
$id = $request->id;
}
$user = $this->userRepo->find($id);
$user = $this->userRepo->find($this->getUserId($request));
$subfleets = $this->userSvc->getAllowableSubfleets($user);
SubfleetResource::withoutWrapping();
return SubfleetResource::collection($subfleets);
}
/**
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
* @throws RepositoryException
*/
public function pireps(Request $request)
{
$this->pirepRepo->pushCriteria(new RequestCriteria($request));
$where = [
'user_id' => $this->getUserId($request),
];
if(filled($request->query('state'))) {
$where['state'] = $request->query('state');
} else {
$where[] = ['state', '!=', PirepState::CANCELLED];
}
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
$pireps = $this->pirepRepo
->orderBy('created_at', 'desc')
->paginate();
return PirepResource::collection($pireps);
}
}

View File

@@ -9,11 +9,17 @@ class ForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
/**
* ForgotPasswordController constructor.
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showLinkRequestForm()
{
return $this->view('auth.passwords.email');

View File

@@ -2,13 +2,12 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;
use App\Models\Enums\UserState;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class LoginController extends Controller
{
@@ -16,11 +15,17 @@ class LoginController extends Controller
protected $redirectTo = '/dashboard';
/**
* LoginController constructor.
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showLoginForm()
{
return $this->view('auth/login');

View File

@@ -2,22 +2,19 @@
namespace App\Http\Controllers\Auth;
use Log;
use Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Auth\RegistersUsers;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use App\Models\User;
use App\Facades\Utils;
use App\Models\Airport;
use App\Models\Airline;
use App\Services\UserService;
use App\Models\Enums\UserState;
use App\Http\Controllers\Controller;
use App\Models\Enums\UserState;
use App\Models\User;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Services\UserService;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Log;
use Validator;
class RegisterController extends Controller
{
@@ -25,7 +22,6 @@ class RegisterController extends Controller
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
@@ -34,7 +30,12 @@ class RegisterController extends Controller
$airportRepo,
$userService;
/**
* RegisterController constructor.
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param UserService $userService
*/
public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
@@ -46,6 +47,9 @@ class RegisterController extends Controller
$this->middleware('guest');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showRegistrationForm()
{
$airports = $this->airportRepo->selectBoxList(false, true);
@@ -60,7 +64,6 @@ class RegisterController extends Controller
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
@@ -77,7 +80,6 @@ class RegisterController extends Controller
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
* @throws \RuntimeException

View File

@@ -2,9 +2,9 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
class ResetPasswordController extends Controller
{
@@ -12,6 +12,11 @@ class ResetPasswordController extends Controller
use ResetsPasswords;
/**
* @param Request $request
* @param null $token
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showResetForm(Request $request, $token = null)
{
return $this->view('auth.passwords.reset',
@@ -21,7 +26,6 @@ class ResetPasswordController extends Controller
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()

View File

@@ -2,10 +2,10 @@
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{

View File

@@ -2,16 +2,20 @@
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Repositories\AcarsRepository;
use App\Services\GeoService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class AcarsController extends Controller
{
private $acarsRepo, $geoSvc;
/**
* AcarsController constructor.
* @param AcarsRepository $acarsRepo
* @param GeoService $geoSvc
*/
public function __construct(
AcarsRepository $acarsRepo,
GeoService $geoSvc
@@ -21,7 +25,8 @@ class AcarsController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{

View File

@@ -2,17 +2,20 @@
namespace App\Http\Controllers\Frontend;
use Log;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Repositories\PirepRepository;
use App\Repositories\UserRepository;
use Illuminate\Support\Facades\Auth;
class DashboardController extends Controller
{
private $pirepRepo, $userRepo;
/**
* DashboardController constructor.
* @param PirepRepository $pirepRepo
* @param UserRepository $userRepo
*/
public function __construct(
PirepRepository $pirepRepo,
UserRepository $userRepo

View File

@@ -2,20 +2,17 @@
namespace App\Http\Controllers\Frontend;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Services\GeoService;
use Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Models\UserBid;
use App\Repositories\FlightRepository;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria;
use Mockery\Exception;
use App\Repositories\FlightRepository;
use App\Services\FlightService;
use App\Services\GeoService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Log;
use Prettus\Repository\Exceptions\RepositoryException;
class FlightController extends Controller
@@ -25,18 +22,32 @@ class FlightController extends Controller
$flightRepo,
$geoSvc;
/**
* FlightController constructor.
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
* @param GeoService $geoSvc
*/
public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
FlightRepository $flightRepo,
FlightService $flightSvc,
GeoService $geoSvc
) {
$this->airlineRepo = $airlineRepo;
$this->airportRepo = $airportRepo;
$this->flightRepo = $flightRepo;
$this->flightSvc = $flightSvc;
$this->geoSvc = $geoSvc;
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
$where = ['active' => true];
@@ -86,38 +97,10 @@ class FlightController extends Controller
]);
}
public function save(Request $request)
{
$user_id = Auth::id();
$flight_id = $request->input('flight_id');
$action = strtolower($request->input('action'));
$cols = ['user_id' => $user_id, 'flight_id' => $flight_id];
if($action === 'save') {
$uf = UserBid::create($cols);
$uf->save();
return response()->json([
'id' => $uf->id,
'message' => 'Saved!',
]);
}
elseif ($action === 'remove') {
try {
$uf = UserBid::where($cols)->first();
$uf->delete();
} catch (Exception $e) { }
return response()->json([
'message' => 'Deleted!'
]);
}
}
/**
* Show the flight information page
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function show($id)
{

View File

@@ -2,9 +2,9 @@
namespace App\Http\Controllers\Frontend;
use Illuminate\Database\QueryException;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Database\QueryException;
class HomeController extends Controller
{

View File

@@ -2,28 +2,26 @@
namespace App\Http\Controllers\Frontend;
use Log;
use App\Facades\Utils;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreatePirepRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Pirep;
use App\Models\PirepField;
use App\Repositories\AcarsRepository;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria;
use App\Repositories\PirepFieldRepository;
use App\Repositories\PirepRepository;
use App\Repositories\SubfleetRepository;
use App\Services\GeoService;
use App\Services\PIREPService;
use App\Services\UserService;
use App\Repositories\Criteria\WhereCriteria;
use App\Http\Controllers\Controller;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\PirepRepository;
use App\Repositories\PirepFieldRepository;
use App\Repositories\SubfleetRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Log;
class PirepController extends Controller
@@ -37,6 +35,17 @@ class PirepController extends Controller
$subfleetRepo,
$userSvc;
/**
* PirepController constructor.
* @param AirlineRepository $airlineRepo
* @param PirepRepository $pirepRepo
* @param AirportRepository $airportRepo
* @param PirepFieldRepository $pirepFieldRepo
* @param GeoService $geoSvc
* @param SubfleetRepository $subfleetRepo
* @param PIREPService $pirepSvc
* @param UserService $userSvc
*/
public function __construct(
AirlineRepository $airlineRepo,
PirepRepository $pirepRepo,
@@ -94,10 +103,7 @@ class PirepController extends Controller
$user = Auth::user();
$where = [['user_id', $user->id]];
if(setting('pireps.hide_cancelled_pireps')) {
$where[] = ['state', '<>', PirepState::CANCELLED];
}
$where[] = ['state', '<>', PirepState::CANCELLED];
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();
@@ -122,14 +128,14 @@ class PirepController extends Controller
}
/**
*
* @param CreatePirepRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Exception
*/
public function store(CreatePirepRequest $request)
{
// Create the main PIREP
$pirep = new Pirep($request->all());
$pirep = new Pirep($request->post());
$pirep->user_id = Auth::user()->id;
# Make sure this isn't a duplicate
@@ -140,8 +146,9 @@ class PirepController extends Controller
}
// Any special fields
$pirep->flight_time = ((int) Utils::hoursToMinutes($request['hours']))
+ ((int) $request['minutes']);
$hours = (int) $request->input('hours', 0);
$minutes = (int) $request->input('minutes', 0);
$pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes;
// The custom fields from the form
$custom_fields = [];
@@ -165,20 +172,23 @@ class PirepController extends Controller
return redirect(route('frontend.pireps.show', ['id' => $pirep->id]));
}
/**
* @param $id
* @return mixed
*/
public function show($id)
{
#$pirep = Pirep::where('id', $id);
$pirep = $this->pirepRepo->find($id);
if (empty($pirep)) {
Flash::error('Pirep not found');
return redirect(route('frontend.pirep.index'));
}
$map_featuers = $this->geoSvc->pirepGeoJson($pirep);
$map_features = $this->geoSvc->pirepGeoJson($pirep);
return $this->view('pireps.show', [
'pirep' => $pirep,
'map_features' => $map_featuers,
'map_features' => $map_features,
]);
}
}

View File

@@ -2,21 +2,20 @@
namespace App\Http\Controllers\Frontend;
use Log;
use Hash;
use Flash;
use Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Facades\Utils;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\UserRepository;
use App\Support\Countries;
use Flash;
use Hash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Jackiedo\Timezonelist\Facades\Timezonelist;
use Log;
use Validator;
class ProfileController extends Controller
{
@@ -24,6 +23,12 @@ class ProfileController extends Controller
$airportRepo,
$userRepo;
/**
* ProfileController constructor.
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param UserRepository $userRepo
*/
public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
@@ -34,6 +39,9 @@ class ProfileController extends Controller
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$airports = $this->airportRepo->all();
@@ -44,6 +52,10 @@ class ProfileController extends Controller
]);
}
/**
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function show($id)
{
$user = User::where('id', $id)->first();
@@ -62,6 +74,8 @@ class ProfileController extends Controller
/**
* Show the edit for form the user's profile
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function edit(Request $request)
{
@@ -74,20 +88,20 @@ class ProfileController extends Controller
$airlines = $this->airlineRepo->selectBoxList();
$airports = $this->airportRepo->selectBoxList();
$countries = collect((new \League\ISO3166\ISO3166)->all())
->mapWithKeys(function($item, $key) {
return [strtolower($item['alpha2']) => $item['name']];
});
return $this->view('profile.edit', [
'user' => $user,
'airlines' => $airlines,
'airports' => $airports,
'countries' => $countries,
'countries' => Countries::getSelectList(),
'timezones' => Timezonelist::toArray(),
]);
}
/**
* @param Request $request
* @return $this
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update(Request $request)
{
$id = Auth::user()->id;
@@ -124,6 +138,8 @@ class ProfileController extends Controller
/**
* Regenerate the user's API key
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function regen_apikey(Request $request)
{

View File

@@ -2,15 +2,18 @@
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Repositories\UserRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
private $userRepo;
/**
* UserController constructor.
* @param UserRepository $userRepo
*/
public function __construct(
UserRepository $userRepo
) {
@@ -18,7 +21,8 @@ class UserController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{

View File

@@ -6,10 +6,9 @@
namespace App\Http\Middleware;
use App\Models\Enums\UserState;
use Auth;
use Log;
use Closure;
use App\Models\User;
use Auth;
use Closure;
class ApiAuth
{

View File

@@ -8,10 +8,8 @@ class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

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