From 6b7eab05e21c2df56e5714a030d32a76f42dcafb Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" <74361521+FatihKoz@users.noreply.github.com> Date: Fri, 19 Feb 2021 16:20:17 +0300 Subject: [PATCH] Assign subfleets from ranks when there are no subfleets on a flight If no subfleets are assigned to a flight, vmsacars was not allowing the flight to be loaded and used 'cause the subfleets was returning null. With this pr, users will be able to use the aircrafts which they have access to by their ranks. ( Same logic was used in SimBrief Controller to populate the aircraft list for flight plan generation ) Co-authored-by: Nabeel S --- app/Services/FlightService.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Services/FlightService.php b/app/Services/FlightService.php index 5cf05a5f..835d7eb9 100644 --- a/app/Services/FlightService.php +++ b/app/Services/FlightService.php @@ -137,6 +137,13 @@ class FlightService extends Service { /** @var \Illuminate\Support\Collection $subfleets */ $subfleets = $flight->subfleets; + + // If no subfleets assigned to a flight get users allowed subfleets + if ($subfleets === null || $subfleets->count() === 0) { + $subfleets = $this->userSvc->getAllowableSubfleets($user); + } + + // If subfleets are still empty return the flight if ($subfleets === null || $subfleets->count() === 0) { return $flight; }