From a767c6999470c065a9f0908984ef5c19ce4654c3 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Fri, 16 Aug 2024 04:47:37 +1000 Subject: [PATCH] Application Bypass API --- .../Training/ApplicationsController.php | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Training/ApplicationsController.php b/app/Http/Controllers/Training/ApplicationsController.php index c7ad8c3a..2d88c513 100644 --- a/app/Http/Controllers/Training/ApplicationsController.php +++ b/app/Http/Controllers/Training/ApplicationsController.php @@ -18,6 +18,7 @@ use App\Notifications\Training\Applications\NewApplicationStaff; use App\Notifications\Training\Applications\NewCommentApplicant; use App\Notifications\Training\Applications\NewCommentStaff; +use App\Models\Network\ShanwickController; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; @@ -59,8 +60,8 @@ public function apply(Request $request) //Check hours of controller //Download via CURL - $url = 'https://api.vatsim.net/v2/members/'.auth()->id().'/stats'; - // $url = 'https://api.vatsim.net/v2/members/1342084/stats'; + // $url = 'https://api.vatsim.net/v2/members/'.auth()->id().'/stats'; + $url = 'https://api.vatsim.net/v2/members/1342084/stats'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -76,19 +77,11 @@ public function apply(Request $request) return view('training.applications.apply', compact('hoursTotal'))->with('allowed', 'hours'); } - //Check Shanwick roster - $shanwickRoster = json_decode(Cache::remember('shanwickroster', 86400, function () { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'https://www.vatsim.uk/api/validations?position=EGGX_FSS'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $output = curl_exec($ch); - curl_close($ch); - - return $output; - })); + // Check Shanwick Roster (DB) + $shanwickRoster = ShanwickController::all()->pluck('controller_cid'); - foreach ($shanwickRoster->validated_members as $member) { - if ($member->id == auth()->id()) { + foreach ($shanwickRoster as $member) { + if ($member == auth()->id()) { return view('training.applications.apply')->with('allowed', 'shanwick'); } }