Example #1
0
 /**
  * Get Information about a specific Character
  *
  * @param int $character_id
  *
  * @return \Seat\Eveapi\Models\Account\ApiKeyInfoCharacters
  */
 public function getCharacterInformation(int $character_id) : ApiKeyInfoCharacters
 {
     return ApiKeyInfoCharacters::join('eve_character_infos', 'eve_character_infos.characterID', '=', 'account_api_key_info_characters.characterID')->where('eve_character_infos.characterID', $character_id)->first();
 }
Example #2
0
 /**
  * Get a list of corporations the current
  * authenticated user has access to
  *
  * @return mixed
  */
 public function getCharacterCorporations()
 {
     $user = auth()->user();
     $corporations = ApiKeyInfoCharacters::join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID')->distinct();
     // If the user us a super user, return all
     if (!$user->hasSuperUser()) {
         $corporations = $corporations->orWhere(function ($query) use($user) {
             // If the user has any affiliations and can
             // list those characters, add them
             if ($user->has('character.list', false)) {
                 $query = $query->whereIn('characterID', array_keys($user->getAffiliationMap()['char']));
             }
             // Add any characters from owner API keys
             $query->orWhere('eve_api_keys.user_id', $user->id);
         });
     }
     return $corporations->orderBy('corporationName')->pluck('corporationName');
 }