diff --git a/app/Http/Controllers/MoonsAdminController.php b/app/Http/Controllers/MoonsAdminController.php index 5b8ac4ad5..b9f248891 100644 --- a/app/Http/Controllers/MoonsAdminController.php +++ b/app/Http/Controllers/MoonsAdminController.php @@ -213,13 +213,9 @@ class MoonsAdminController extends Controller if($contact != null) { $contact = $contact->toArray(); - } - - if(!isset($contact['Contact'])) { - $contact = 'None'; - } else { - //Get the name of the character $contact = $lookup->CharacterName($contact['Contact']); + } else { + $contact = 'None'; } //Set the color for the table diff --git a/app/Library/Lookups/LookupHelper.php b/app/Library/Lookups/LookupHelper.php index 89644d6e4..7b2417b77 100644 --- a/app/Library/Lookups/LookupHelper.php +++ b/app/Library/Lookups/LookupHelper.php @@ -16,16 +16,17 @@ use App\Models\Lookups\CorporationToAlliance; class LookupHelper { public function CharacterName($charId) { - $name = ''; - $temp = CharacterToCorporation::where(['character_id' => $charId])->get(['character_name']); + $esi = new Esye(); - if(!isset($temp->character_name)) { - $name = 'None'; - } else { - $name = $temp->character_name; + try { + $character = $esi->invoke('get', '/characters/{character_id}/', [ + 'character_id' => $charId, + ]); + } catch(RequestFailedException $e){ + return null; } - return $name; + return $character->name; } //Create a character id from a character name