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 <nabeelio@users.noreply.github.com>
This commit is contained in:
B.Fatih KOZ
2021-02-19 16:20:17 +03:00
committed by GitHub
parent 4c8e31ac6f
commit 6b7eab05e2

View File

@@ -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;
}