diff --git a/app/Http/Controllers/FleetsController.php b/app/Http/Controllers/FleetsController.php index 436bd40b4..e3d3a654e 100644 --- a/app/Http/Controllers/FleetsController.php +++ b/app/Http/Controllers/FleetsController.php @@ -65,8 +65,6 @@ class FleetsController extends Controller $fleet->SetFleetEndTime($endTime); //Set the fleet into the session to be used later session(['fleet' => $fleet]); - $fleet = session('fleet'); - dd($fleet); //Return the view with the success message return view('fleets.displayfleets')->with('success', 'Fleet registered.'); @@ -81,7 +79,7 @@ class FleetsController extends Controller $fleet = session('fleet'); dd($fleet); //Add a pilot to the fleet - $error = $fleet->AddPilot(Auth::user()->character_id); + $error = $fleet->AddPilot($id); if($error) { return view('fleets.displaystanding')->with('error', 'Unable to add to fleet.'); } else { @@ -89,9 +87,9 @@ class FleetsController extends Controller } } - public function updateFleet(Request $request) { + public function updateFleet() { //Retrieve the fleet from the session - $fleet = $request->session()->get('fleet'); + $fleet = session('fleet'); $fleet->UpdateFleet($request->isFreeMove, $request->motd); return view('fleets.displaystanding')->with('success', 'Fleet updated.'); diff --git a/app/Library/Fleet.php b/app/Library/Fleet.php index c1c778570..da2937ad7 100644 --- a/app/Library/Fleet.php +++ b/app/Library/Fleet.php @@ -82,7 +82,24 @@ class Fleet { public function AddPilot($charId) { //Get the ESI token for the FC to add the new pilot $token = DB::table('EsiTokens')->where('character_id', $this->fcId)->first(); - //Create the ESI Call + //Create the ESI Call Container + $authentication = new EsiAuthentication([ + 'client_id' => env('ESI_CLIENT_ID'), + 'secret' => env('ESI_SECRET_KEY'), + 'refresh_token' => $token->refresh_token, + ]); + //Crate the ESI Class + $esi = new Eseye($authentication); + //Perform the call to ESI + $error = $esi->invoke('post', '/fleets/{fleet_id}/members/', [ + 'fleet_id' => $this->fleet, + 'invitation' => [ + 'character_id' => $charId, + 'role' => 'squad_member', + ], + ]); + + return $error; } public function RenderFleetDisplay() {