/**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     // Instead of using the 'exists' validation rule, we opt to use
     // the 'in' rule. We do this because we want to add '0' as a valid
     // value, which will signal a wild card for either all characters
     // or all corporations.
     $character_ids = implode(',', array_prepend(ApiKeyInfoCharacters::pluck('characterID')->toArray(), 0));
     $corporation_ids = implode(',', array_prepend(CorporationSheet::pluck('corporationID')->toArray(), 0));
     return ['id' => 'required|numeric|exists:notification_groups,id', 'characters' => 'required_without_all:corporations', 'corporations' => 'required_without_all:characters', 'characters.*' => 'in:' . $character_ids, 'corporations.*' => 'in:' . $corporation_ids];
 }
Example #2
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $user_id = auth()->user()->id;
     // For some fail reson I cant get the UserRepository trait
     // to be happy here.
     // TODO: Fix that!
     $allowed_main_character_ids = implode(',', ApiKeyInfoCharacters::with('key')->whereHas('key', function ($query) use($user_id) {
         $query->where('user_id', $user_id);
     })->pluck('characterID')->toArray());
     $allowed_skins = implode(',', Profile::$options['skins']);
     $allowed_languages = implode(',', array_map(function ($entry) {
         return $entry['short'];
     }, config('web.locale.languages')));
     $allowed_sidebar = implode(',', Profile::$options['sidebar']);
     return ['main_character_id' => 'required|in:' . $allowed_main_character_ids, 'skin' => 'required|in:' . $allowed_skins, 'language' => 'required|in:' . $allowed_languages, 'sidebar' => 'required|in:' . $allowed_sidebar, 'thousand_seperator' => 'in:" ",",","."|size:1', 'decimal_seperator' => 'required|in:",","."|size:1', 'email_notifications' => 'required|in:yes,no', 'require_mfa' => 'required|in:yes,no'];
 }
Example #3
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $result = $this->setScope('account')->getPheal()->APIKeyInfo();
     $key_info = ApiKeyInfoModel::firstOrNew(['keyID' => $this->api_info->key_id]);
     $key_info->fill(['accessMask' => $result->key->accessMask, 'type' => $result->key->type, 'expires' => strlen($result->key->expires) > 0 ? $result->key->expires : null]);
     $key_info->save();
     // Lets process the characters for this API
     // Key. We need to be aware of the fact that it
     // is possible for characters to move around.
     foreach ($result->key->characters as $character) {
         $character_info = ApiKeyInfoCharacters::firstOrNew(['keyID' => $this->api_info->key_id, 'characterID' => $character->characterID]);
         $character_info->fill(['characterName' => $character->characterName, 'corporationID' => $character->corporationID, 'corporationName' => $character->corporationName]);
         $character_info->save();
     }
     // Cleanup Characters no longer on this key
     ApiKeyInfoCharacters::where('keyID', $this->api_info->key_id)->whereNotIn('characterID', array_map(function ($character) {
         return $character->characterID;
     }, (array) $result->key->characters))->delete();
     return;
 }
Example #4
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 #5
0
 /**
  * Returns the characters on a API Key
  *
  * @param $key_id
  *
  * @return mixed
  */
 public function getCharactersOnApiKey($key_id)
 {
     return ApiKeyInfoCharacters::where('keyID', $key_id)->get();
 }
Example #6
0
 /**
  * @param $user_id
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getUserCharacters($user_id)
 {
     return ApiKeyInfoCharacters::with('key')->whereHas('key', function ($query) use($user_id) {
         $query->where('user_id', $user_id);
     })->get();
 }