diff --git a/app/Http/Controllers/FinancesController.php b/app/Http/Controllers/FinancesController.php deleted file mode 100644 index b2dc969e5..000000000 --- a/app/Http/Controllers/FinancesController.php +++ /dev/null @@ -1,12 +0,0 @@ -middleware('auth'); - $this->middleware('role:User'); - } - - /** - * Records fleet activity when requested from the fleet info page - * - * @var fleetId - */ - public function storeFleetActivity($fleetId) { - $fleet = new FleetHelper(); - $fleet->StoreFleetActivity($fleetId); - - return redirect('/display/fleets')->with('success', 'Fleet activity recorded.'); - } - - /** - * Displays the blade for registering a fleet - * - * @var (none) - */ - public function displayRegisterFleet() { - return view('fleets.registerfleet'); - } - - /** - * Work in progress. Doesn't do anything yet. - * - * @var (none) - */ - public function displayFleetSetup() { - - return 0; - } - - /** - * Displays all currently recorded fleets - * - * @var (none) - */ - public function displayFleets() { - $fleets = Fleet::all(); - $data = array(); - $fc = array(); - $fleet = array(); - $description = array(); - $i = 0; - - foreach($fleets as $fl) { - $fc[$i] = $fl->character_id; - $fleet[$i] = $fl->fleet; - $description[$i] = $fl->description; - $i++; - } - - $data = [ - $fc, - $fleet, - $description, - ]; - - //Return the view with the array of the fleet - return view('fleets.displayfleets')->with('data', $data); - } - - /** - * Allows a person to register a fleet through services. - * - * @var Request - */ - public function registerFleet(Request $request) { - //Register a new instance of the fleet class - $fleet = new FleetHelper(Auth::user()->character_id, $request->fleetUri); - $esiHelper = new Esi(); - if(!$esiHelper->HaveEsiScope(Auth::user()->character_id, 'esi-fleets.write_fleet.v1')) { - return view('inc.error')->with('error', 'User does not have the write fleet scope.'); - } - - //Make the fleet uri so we can call later functions - $fleetUri = $fleet->GetFleetUri(); - - //Check for the fleet in the database - $check = DB::table('Fleets')->where('fleet', $fleetUri)->first(); - //If we do not find the fleet, let's create it. - if($check === null) { - // Insert the fleet into the table - DB::table('Fleets')->insert([ - 'character_id' => Auth::user()->character_id, - 'fleet' => $fleetUri, - 'description' => $request->description, - 'creation_time' => $current, - ]); - } - - return redirect('/fleets/display'); - } - - /** - * Deletes a fleet of fleetId - * - * @var fleetId - */ - public function deleteFleet($fleetId) { - DB::table('Fleets')->where('fleet', $fleetId)->delete(); - return redirect('/fleets/display'); - } - - /** - * Add a pilot to the fleet - * - * @var fleetId - * @var charId - */ - public function addPilot($fleetId, $charId) { - $newPilot = new FleetHelper(); - - //Retrieve the fleet data - $fleet = DB::table('Fleets')->where('fleet', $fleetId)->get(); - /** - * Add the pilot to the fleet - * @var fleet[0]->character_id is the FC of the fleet to get the refresh token - * @var charId is the character being added to the fleet - * @var fleetId is the number of the fleet to be retrieved from the database - */ - $error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId); - //If we don't have an error go back to the dashboard, - //Otherwise, send the user to the error screen and print the error out. - if($error === null) { - return view('/dashboard')->with('success', 'Invite for fleet sent.'); - } else { - return view('inc.error')->with('error', $error); - } - } - - /** - * Add a pilot by his name rather than allowing him to click on the link - * - * @var fleetId - * @var name - */ - public function addPilotName($fleetId, $name) { - $newPilot = new FleetHelper(); - $esiHelper = new Esi(); - - //Retrieve the fleet data - $fleet = DB::table('Fleets')->where('fleet', $fleetId)->get(); - //Search for the pilot's character id through his name - $charId = $esiHelper->FindCharacterId($name); - /** - * Add the pilot to the fleet - * @var fleet[0]->character_id is the FC of the fleet to get the refresh token - * @var charId is the character being added to the fleet - * @var fleetId is the number of the fleet to be retrieved from the database - */ - $error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId); - //If we don't have an error go back to the dashboard, - //Otherwise, send the user to the error screen and print the error out. - if($error === null) { - return view('/dashboard')->with('success', 'Invite for fleet sent.'); - } else { - return view('inc.error')->with('error', $error); - } - } - - /** - * Update a fleet based on a session variable - * - * @var session - */ - public function updateFleet() { - //Retrieve the fleet from the session - $fleet = session('fleet'); - $fleet->UpdateFleet($request->isFreeMove, $request->motd); - - return redirect('/fleets/display'); - } -} diff --git a/app/Library/Clones/CloneSaver.php b/app/Library/Clones/CloneSaver.php deleted file mode 100644 index 6f2e85d87..000000000 --- a/app/Library/Clones/CloneSaver.php +++ /dev/null @@ -1,35 +0,0 @@ -cache = NullCache::class; + //Setup class variables $esi = new Eseye(); - - + //Attempt to find the character name in the LookupCharacter table to see if we can match it to an id + $charId = + + //Get the character id from the ESI API. + $response = $esi->setQueryString([ + 'categories' => 'character', + 'search' => $character, + 'strict' => 'true', + ])->invoke('get', '/search/'); + + return $reponse[0]; } //Add characters to the lookup table for quicker lookups without having @@ -52,7 +64,7 @@ class LookupHelper { } //Save all of the data to the database - $char = new UserToCorporation; + $char = new CharacterToCorporation; $char->character_id = $charId; $char->character_name = $character->name; $char->corporation_id = $character->corporation_id; @@ -72,7 +84,7 @@ class LookupHelper { $esi = new Eseye(); //Get all of the data from the database and start performing updates - $dbChars = UserToCorporation::all(); + $dbChars = CharacterToCorporation::all(); foreach($dbChars as $char) { //Attempt to get the data from the ESI API try{ @@ -92,7 +104,7 @@ class LookupHelper { } catch(RequestFailedException $e) { return $e->getEsiResponse(); } - UserToCorporation::where(['character_id' => $char->character_id]) + CharacterToCorporation::where(['character_id' => $char->character_id]) ->update([ 'corporation_id' => $character->corporation_id, 'corporation_name' => $corporation->name, diff --git a/app/Models/Charcter/CharacterToCorporation.php b/app/Models/Lookups/CharacterToCorporation.php similarity index 93% rename from app/Models/Charcter/CharacterToCorporation.php rename to app/Models/Lookups/CharacterToCorporation.php index 131cf94cc..003207849 100644 --- a/app/Models/Charcter/CharacterToCorporation.php +++ b/app/Models/Lookups/CharacterToCorporation.php @@ -1,6 +1,6 @@