Apply fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
20f46adbc4
commit
9596d88b48
@@ -23,17 +23,17 @@ use Log;
|
||||
|
||||
/**
|
||||
* Class AcarsController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AcarsController extends Controller
|
||||
{
|
||||
private $acarsRepo,
|
||||
$geoSvc,
|
||||
$pirepRepo,
|
||||
$pirepSvc;
|
||||
private $acarsRepo;
|
||||
private $geoSvc;
|
||||
private $pirepRepo;
|
||||
private $pirepSvc;
|
||||
|
||||
/**
|
||||
* AcarsController constructor.
|
||||
*
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param GeoService $geoSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
@@ -53,7 +53,9 @@ class AcarsController extends Controller
|
||||
|
||||
/**
|
||||
* Check if a PIREP is cancelled
|
||||
*
|
||||
* @param $pirep
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*/
|
||||
protected function checkCancelled(Pirep $pirep)
|
||||
@@ -65,7 +67,9 @@ class AcarsController extends Controller
|
||||
|
||||
/**
|
||||
* Return all of the flights (as points) in GeoJSON format
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
@@ -74,14 +78,16 @@ class AcarsController extends Controller
|
||||
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
|
||||
|
||||
return response(json_encode($positions), 200, [
|
||||
'Content-type' => 'application/json'
|
||||
'Content-type' => 'application/json',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the GeoJSON for the ACARS line
|
||||
*
|
||||
* @param $pirep_id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
public function acars_geojson($pirep_id, Request $request)
|
||||
@@ -96,8 +102,10 @@ class AcarsController extends Controller
|
||||
|
||||
/**
|
||||
* Return the routes for the ACARS line
|
||||
*
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return AcarsRouteResource
|
||||
*/
|
||||
public function acars_get($id, Request $request)
|
||||
@@ -106,21 +114,24 @@ class AcarsController extends Controller
|
||||
|
||||
return new AcarsRouteResource(Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::FLIGHT_PATH
|
||||
'type' => AcarsType::FLIGHT_PATH,
|
||||
])->orderBy('sim_time', 'asc')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Post ACARS updates for a PIREP
|
||||
*
|
||||
* @param $id
|
||||
* @param PositionRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function acars_store($id, PositionRequest $request)
|
||||
{
|
||||
# Check if the status is cancelled...
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
@@ -146,10 +157,10 @@ class AcarsController extends Controller
|
||||
$update = Acars::create($position);
|
||||
$update->save();
|
||||
|
||||
++$count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
# Change the PIREP status if it's as SCHEDULED before
|
||||
// Change the PIREP status if it's as SCHEDULED before
|
||||
if ($pirep->status === PirepStatus::INITIATED) {
|
||||
$pirep->status = PirepStatus::AIRBORNE;
|
||||
}
|
||||
@@ -162,15 +173,18 @@ class AcarsController extends Controller
|
||||
/**
|
||||
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
|
||||
* But rather in a log file.
|
||||
*
|
||||
* @param $id
|
||||
* @param LogRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function acars_logs($id, LogRequest $request)
|
||||
{
|
||||
# Check if the status is cancelled...
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
@@ -192,7 +206,7 @@ class AcarsController extends Controller
|
||||
|
||||
$acars = Acars::create($log);
|
||||
$acars->save();
|
||||
++$count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $this->message($count.' logs added', $count);
|
||||
@@ -201,15 +215,18 @@ class AcarsController extends Controller
|
||||
/**
|
||||
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
|
||||
* But rather in a log file.
|
||||
*
|
||||
* @param $id
|
||||
* @param EventRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function acars_events($id, EventRequest $request)
|
||||
{
|
||||
# Check if the status is cancelled...
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
@@ -232,7 +249,7 @@ class AcarsController extends Controller
|
||||
|
||||
$acars = Acars::create($log);
|
||||
$acars->save();
|
||||
++$count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $this->message($count.' logs added', $count);
|
||||
|
||||
@@ -9,7 +9,6 @@ use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class AirlineController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AirlineController extends Controller
|
||||
{
|
||||
@@ -17,6 +16,7 @@ class AirlineController extends Controller
|
||||
|
||||
/**
|
||||
* AirlineController constructor.
|
||||
*
|
||||
* @param AirlineRepository $airlineRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -27,12 +27,14 @@ class AirlineController extends Controller
|
||||
|
||||
/**
|
||||
* Return all the airlines, paginated
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
#$this->airlineRepo->pushCriteria(new RequestCriteria($request));
|
||||
//$this->airlineRepo->pushCriteria(new RequestCriteria($request));
|
||||
$airports = $this->airlineRepo
|
||||
->whereOrder(['active' => true], 'name', 'asc')
|
||||
->paginate();
|
||||
@@ -42,7 +44,9 @@ class AirlineController extends Controller
|
||||
|
||||
/**
|
||||
* Do a lookup, via vaCentral, for the airport information
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return AirlineResource
|
||||
*/
|
||||
public function get($id)
|
||||
|
||||
@@ -12,7 +12,6 @@ use VaCentral\Airport as AirportLookup;
|
||||
|
||||
/**
|
||||
* Class AirportController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AirportController extends Controller
|
||||
{
|
||||
@@ -20,6 +19,7 @@ class AirportController extends Controller
|
||||
|
||||
/**
|
||||
* AirportController constructor.
|
||||
*
|
||||
* @param AirportRepository $airportRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -30,7 +30,9 @@ class AirportController extends Controller
|
||||
|
||||
/**
|
||||
* Return all the airports, paginated
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
@@ -65,7 +67,9 @@ class AirportController extends Controller
|
||||
|
||||
/**
|
||||
* Do a lookup, via vaCentral, for the airport information
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return AirportResource
|
||||
*/
|
||||
public function get($id)
|
||||
@@ -77,7 +81,9 @@ class AirportController extends Controller
|
||||
|
||||
/**
|
||||
* Do a lookup, via vaCentral, for the airport information
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return AirportResource
|
||||
*/
|
||||
public function lookup($id)
|
||||
|
||||
@@ -11,15 +11,15 @@ use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class FleetController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class FleetController extends Controller
|
||||
{
|
||||
private $aircraftRepo,
|
||||
$subfleetRepo;
|
||||
private $aircraftRepo;
|
||||
private $subfleetRepo;
|
||||
|
||||
/**
|
||||
* FleetController constructor.
|
||||
*
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
*/
|
||||
@@ -47,8 +47,10 @@ class FleetController extends Controller
|
||||
/**
|
||||
* Get a specific aircraft. Query string required to specify the tail
|
||||
* /api/aircraft/XYZ?type=registration
|
||||
*
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return AircraftResource
|
||||
*/
|
||||
public function get_aircraft($id, Request $request)
|
||||
|
||||
@@ -15,15 +15,15 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
/**
|
||||
* Class FlightController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class FlightController extends Controller
|
||||
{
|
||||
private $flightRepo,
|
||||
$flightSvc;
|
||||
private $flightRepo;
|
||||
private $flightSvc;
|
||||
|
||||
/**
|
||||
* FlightController constructor.
|
||||
*
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
*/
|
||||
@@ -37,7 +37,9 @@ class FlightController extends Controller
|
||||
|
||||
/**
|
||||
* Return all the flights, paginated
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function index(Request $request)
|
||||
@@ -49,7 +51,7 @@ class FlightController extends Controller
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
if(setting('pilots.restrict_to_company')) {
|
||||
if (setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
}
|
||||
if (setting('pilots.only_flights_from_current', false)) {
|
||||
@@ -69,6 +71,7 @@ class FlightController extends Controller
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return FlightResource
|
||||
*/
|
||||
public function get($id)
|
||||
@@ -81,6 +84,7 @@ class FlightController extends Controller
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function search(Request $request)
|
||||
@@ -93,7 +97,7 @@ class FlightController extends Controller
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
if(setting('pilots.restrict_to_company')) {
|
||||
if (setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
}
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
@@ -117,8 +121,10 @@ class FlightController extends Controller
|
||||
|
||||
/**
|
||||
* Get a flight's route
|
||||
*
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function route($id, Request $request)
|
||||
|
||||
@@ -7,24 +7,25 @@ use App\Interfaces\Controller;
|
||||
use App\Repositories\NewsRepository;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class NewsController extends Controller
|
||||
{
|
||||
private $newsRepo;
|
||||
|
||||
/**
|
||||
* AirlineController constructor.
|
||||
*
|
||||
* @param NewsRepository $newsRepo
|
||||
*/
|
||||
public function __construct(NewsRepository $newsRepo) {
|
||||
public function __construct(NewsRepository $newsRepo)
|
||||
{
|
||||
$this->newsRepo = $newsRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the airlines, paginated
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
|
||||
@@ -40,20 +40,20 @@ use Log;
|
||||
|
||||
/**
|
||||
* Class PirepController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $acarsRepo,
|
||||
$fareSvc,
|
||||
$financeSvc,
|
||||
$journalRepo,
|
||||
$pirepRepo,
|
||||
$pirepSvc,
|
||||
$userSvc;
|
||||
private $acarsRepo;
|
||||
private $fareSvc;
|
||||
private $financeSvc;
|
||||
private $journalRepo;
|
||||
private $pirepRepo;
|
||||
private $pirepSvc;
|
||||
private $userSvc;
|
||||
|
||||
/**
|
||||
* PirepController constructor.
|
||||
*
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param PirepFinanceService $financeSvc
|
||||
@@ -82,7 +82,9 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Parse any PIREP added in
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return array|null|string
|
||||
*/
|
||||
protected function parsePirep(Request $request)
|
||||
@@ -98,7 +100,9 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Check if a PIREP is cancelled
|
||||
*
|
||||
* @param $pirep
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*/
|
||||
protected function checkCancelled(Pirep $pirep)
|
||||
@@ -132,8 +136,10 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Save the fares
|
||||
*
|
||||
* @param $pirep
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function updateFares($pirep, Request $request)
|
||||
@@ -155,14 +161,15 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Get all the active PIREPs
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$active = [];
|
||||
$pireps = $this->acarsRepo->getPositions();
|
||||
foreach($pireps as $pirep) {
|
||||
if(!$pirep->position) {
|
||||
foreach ($pireps as $pirep) {
|
||||
if (!$pirep->position) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -174,6 +181,7 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* @param $pirep_id
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function get($pirep_id)
|
||||
@@ -187,12 +195,14 @@ class PirepController extends Controller
|
||||
* status, and whatever other statuses may be defined
|
||||
*
|
||||
* @param PrefileRequest $request
|
||||
* @return PirepResource
|
||||
*
|
||||
* @throws \App\Exceptions\AircraftNotAtAirport
|
||||
* @throws \App\Exceptions\UserNotAtAirport
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \App\Exceptions\AircraftPermissionDenied
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function prefile(PrefileRequest $request)
|
||||
{
|
||||
@@ -211,28 +221,25 @@ class PirepController extends Controller
|
||||
|
||||
$pirep = new Pirep($attrs);
|
||||
|
||||
# See if this user is at the current airport
|
||||
// See if this user is at the current airport
|
||||
if (setting('pilots.only_flights_from_current')
|
||||
&& $user->curr_airport_id !== $pirep->dpt_airport_id)
|
||||
{
|
||||
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
|
||||
throw new UserNotAtAirport();
|
||||
}
|
||||
|
||||
# See if this user is allowed to fly this aircraft
|
||||
// See if this user is allowed to fly this aircraft
|
||||
if (setting('pireps.restrict_aircraft_to_rank', false)
|
||||
&& !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id))
|
||||
{
|
||||
&& !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id)) {
|
||||
throw new AircraftPermissionDenied();
|
||||
}
|
||||
|
||||
# See if this aircraft is at the departure airport
|
||||
// See if this aircraft is at the departure airport
|
||||
if (setting('pireps.only_aircraft_at_dpt_airport')
|
||||
&& $pirep->aircraft_id !== $pirep->dpt_airport_id)
|
||||
{
|
||||
&& $pirep->aircraft_id !== $pirep->dpt_airport_id) {
|
||||
throw new AircraftNotAtAirport();
|
||||
}
|
||||
|
||||
# Find if there's a duplicate, if so, let's work on that
|
||||
// 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;
|
||||
@@ -240,7 +247,7 @@ class PirepController extends Controller
|
||||
}
|
||||
|
||||
// Default to a scheduled passenger flight
|
||||
if(!array_key_exists('flight_type', $attrs)) {
|
||||
if (!array_key_exists('flight_type', $attrs)) {
|
||||
$attrs['flight_type'] = 'J';
|
||||
}
|
||||
|
||||
@@ -262,11 +269,13 @@ class PirepController extends Controller
|
||||
*
|
||||
* @param $pirep_id
|
||||
* @param UpdateRequest $request
|
||||
* @return PirepResource
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \App\Exceptions\AircraftPermissionDenied
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function update($pirep_id, UpdateRequest $request)
|
||||
{
|
||||
@@ -280,7 +289,7 @@ class PirepController extends Controller
|
||||
$attrs = $this->parsePirep($request);
|
||||
$attrs['user_id'] = Auth::id();
|
||||
|
||||
# If aircraft is being changed, see if this user is allowed to fly this aircraft
|
||||
// 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)
|
||||
) {
|
||||
@@ -299,13 +308,16 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* File the PIREP
|
||||
*
|
||||
* @param $pirep_id
|
||||
* @param FileRequest $request
|
||||
* @return PirepResource
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \App\Exceptions\AircraftPermissionDenied
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function file($pirep_id, FileRequest $request)
|
||||
{
|
||||
@@ -313,13 +325,13 @@ class PirepController extends Controller
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
# Check if the status is cancelled...
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($pirep_id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
$attrs = $this->parsePirep($request);
|
||||
|
||||
# If aircraft is being changed, see if this user is allowed to fly this aircraft
|
||||
// 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)
|
||||
) {
|
||||
@@ -343,9 +355,9 @@ class PirepController extends Controller
|
||||
Log::error($e);
|
||||
}
|
||||
|
||||
# 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
|
||||
// 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) {
|
||||
@@ -357,10 +369,13 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Cancel the PIREP
|
||||
*
|
||||
* @param $pirep_id
|
||||
* @param Request $request
|
||||
* @return PirepResource
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return PirepResource
|
||||
*/
|
||||
public function cancel($pirep_id, Request $request)
|
||||
{
|
||||
@@ -376,7 +391,9 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Add a new comment
|
||||
* @param $id
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function comments_get($id)
|
||||
@@ -387,10 +404,13 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Add a new comment
|
||||
*
|
||||
* @param $id
|
||||
* @param CommentRequest $request
|
||||
* @return PirepCommentResource
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
*
|
||||
* @return PirepCommentResource
|
||||
*/
|
||||
public function comments_post($id, CommentRequest $request)
|
||||
{
|
||||
@@ -399,7 +419,7 @@ class PirepController extends Controller
|
||||
|
||||
Log::debug('Posting comment, PIREP: '.$id, $request->post());
|
||||
|
||||
# Add it
|
||||
// Add it
|
||||
$comment = new PirepComment($request->post());
|
||||
$comment->pirep_id = $id;
|
||||
$comment->user_id = Auth::id();
|
||||
@@ -410,7 +430,9 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Get all of the fields for a PIREP
|
||||
*
|
||||
* @param $pirep_id
|
||||
*
|
||||
* @return PirepFieldCollection
|
||||
*/
|
||||
public function fields_get($pirep_id)
|
||||
@@ -421,8 +443,10 @@ class PirepController extends Controller
|
||||
|
||||
/**
|
||||
* Set any fields for a PIREP
|
||||
*
|
||||
* @param string $pirep_id
|
||||
* @param FieldsRequest $request
|
||||
*
|
||||
* @return PirepFieldCollection
|
||||
*/
|
||||
public function fields_post($pirep_id, FieldsRequest $request)
|
||||
@@ -436,10 +460,12 @@ class PirepController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
* @param $id
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function finances_get($id)
|
||||
{
|
||||
@@ -451,11 +477,13 @@ class PirepController extends Controller
|
||||
/**
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \Exception
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function finances_recalculate($id, Request $request)
|
||||
{
|
||||
@@ -471,6 +499,7 @@ class PirepController extends Controller
|
||||
/**
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function route_get($id, Request $request)
|
||||
@@ -478,22 +507,25 @@ class PirepController extends Controller
|
||||
$pirep = Pirep::find($id);
|
||||
return AcarsRouteResource::collection(Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::ROUTE
|
||||
'type' => AcarsType::ROUTE,
|
||||
])->orderBy('order', 'asc')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the ROUTE for a PIREP, can be done from the ACARS log
|
||||
*
|
||||
* @param $id
|
||||
* @param RouteRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function route_post($id, RouteRequest $request)
|
||||
{
|
||||
# Check if the status is cancelled...
|
||||
// Check if the status is cancelled...
|
||||
$pirep = Pirep::find($id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
@@ -502,7 +534,7 @@ class PirepController extends Controller
|
||||
// Delete the route before posting a new one
|
||||
Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::ROUTE
|
||||
'type' => AcarsType::ROUTE,
|
||||
])->delete();
|
||||
|
||||
$count = 0;
|
||||
@@ -518,7 +550,7 @@ class PirepController extends Controller
|
||||
$acars = Acars::create($position);
|
||||
$acars->save();
|
||||
|
||||
++$count;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $this->message($count.' points added', $count);
|
||||
@@ -527,8 +559,10 @@ class PirepController extends Controller
|
||||
/**
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function route_delete($id, Request $request)
|
||||
{
|
||||
@@ -536,7 +570,7 @@ class PirepController extends Controller
|
||||
|
||||
Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::ROUTE
|
||||
'type' => AcarsType::ROUTE,
|
||||
])->delete();
|
||||
|
||||
return $this->message('Route deleted');
|
||||
|
||||
@@ -9,7 +9,6 @@ use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class SettingsController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
@@ -17,6 +16,7 @@ class SettingsController extends Controller
|
||||
|
||||
/**
|
||||
* SettingsController constructor.
|
||||
*
|
||||
* @param SettingRepository $settingRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -27,7 +27,9 @@ class SettingsController extends Controller
|
||||
|
||||
/**
|
||||
* Return all the airlines, paginated
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function index(Request $request)
|
||||
|
||||
@@ -7,7 +7,6 @@ use PragmaRX\Version\Package\Facade as Version;
|
||||
|
||||
/**
|
||||
* Class StatusController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class StatusController extends Controller
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Exceptions\BidExists;
|
||||
use App\Http\Resources\Bid as BidResource;
|
||||
use App\Http\Resources\Pirep as PirepResource;
|
||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||
@@ -24,19 +23,19 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
/**
|
||||
* Class UserController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
private $flightRepo,
|
||||
$flightSvc,
|
||||
$pirepRepo,
|
||||
$subfleetRepo,
|
||||
$userRepo,
|
||||
$userSvc;
|
||||
private $flightRepo;
|
||||
private $flightSvc;
|
||||
private $pirepRepo;
|
||||
private $subfleetRepo;
|
||||
private $userRepo;
|
||||
private $userSvc;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
*
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
@@ -62,6 +61,7 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return int|mixed
|
||||
*/
|
||||
protected function getUserId(Request $request)
|
||||
@@ -75,7 +75,9 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* Return the profile for the currently auth'd user
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return UserResource
|
||||
*/
|
||||
public function index(Request $request)
|
||||
@@ -85,7 +87,9 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* Get the profile for the passed-in user
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return UserResource
|
||||
*/
|
||||
public function get($id)
|
||||
@@ -95,16 +99,19 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* Return all of the bids for the passed-in user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
* @throws \App\Exceptions\BidExists
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function bids(Request $request)
|
||||
{
|
||||
$user = $this->userRepo->find($this->getUserId($request));
|
||||
|
||||
# Add a bid
|
||||
// Add a bid
|
||||
if ($request->isMethod('PUT') || $request->isMethod('POST')) {
|
||||
$flight_id = $request->input('flight_id');
|
||||
$flight = $this->flightRepo->find($flight_id);
|
||||
@@ -125,7 +132,7 @@ class UserController extends Controller
|
||||
$this->flightSvc->removeBid($flight, $user);
|
||||
}
|
||||
|
||||
# Return the flights they currently have bids on
|
||||
// Return the flights they currently have bids on
|
||||
$bids = Bid::where(['user_id' => $user->id])->get();
|
||||
|
||||
return BidResource::collection($bids);
|
||||
@@ -133,7 +140,9 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* Return the fleet that this user is allowed to
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function fleet(Request $request)
|
||||
@@ -146,8 +155,10 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function pireps(Request $request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user