diff --git a/app/Library/Lookups/LookupHelper.php b/app/Library/Lookups/LookupHelper.php index d5dacda57..e7a8fa366 100644 --- a/app/Library/Lookups/LookupHelper.php +++ b/app/Library/Lookups/LookupHelper.php @@ -24,16 +24,21 @@ class LookupHelper { $esi = new Eseye(); //Attempt to find the character name in the LookupCharacter table to see if we can match it to an id - $charId = + $charId = CharacterToCorporation::where(['character_name' => $character])->get('character_id'); + if($charId == null) { + //Get the character id from the ESI API. + $response = $esi->setQueryString([ + 'categories' => 'character', + 'search' => $character, + 'strict' => 'true', + ])->invoke('get', '/search/'); - //Get the character id from the ESI API. - $response = $esi->setQueryString([ - 'categories' => 'character', - 'search' => $character, - 'strict' => 'true', - ])->invoke('get', '/search/'); + $this->LookupCharacter($response->character[0]); - return $reponse->character[0]; + return $response->character[0]; + } else { + return $charId[0]->character_id; + } } //Add characters to the lookup table for quicker lookups without having