diff --git a/app/Http/Controllers/TrainingController.php b/app/Http/Controllers/TrainingController.php index b5443c79..56f21e67 100644 --- a/app/Http/Controllers/TrainingController.php +++ b/app/Http/Controllers/TrainingController.php @@ -285,11 +285,11 @@ public function store(Request $request) } else { $res = $client->request('GET', 'https://api.vatsim.net/v2/members/819096/stats'); } - + // Process the data if we got a 200 OK if ($res->getStatusCode() == 200) { $vatsimStats = json_decode($res->getBody(), true); - + if (isset($vatsimStats[strtolower(\Auth::user()->rating_short)])) { $vatsimHours = $vatsimStats[strtolower(\Auth::user()->rating_short)]; } else { @@ -299,7 +299,7 @@ public function store(Request $request) return redirect()->back()->withErrors('We were unable to load the application for you due to missing data from VATSIM. Please try again later.'); } } catch (\GuzzleHttp\Exception\ClientException $e) { - + // If the resource returns 404 and user is S1, it just means the user has no hours yet and can apply for training if ($e->getResponse()->getStatusCode() == 404 && \Auth::user()->rating == VatsimRating::OBS->value) { $vatsimHours = 0;