public function checkForUpdate($gamertag = '')
 {
     if ($this->request->ajax() && !\Agent::isRobot()) {
         try {
             $account = Account::with('destiny.characters')->where('seo', Text::seoGamertag($gamertag))->firstOrFail();
             // We don't care about non-panda members
             if (!$account->isPandaLove()) {
                 $this->inactiveCounter = 1;
             }
             // check for 10 inactive checks
             if ($account->destiny->inactiveCounter >= $this->inactiveCounter) {
                 return response()->json(['updated' => false, 'frozen' => true, 'last_update' => 'This account hasn\'t had new data in awhile. - <a href="' . URL::action('Destiny\\ProfileController@manualUpdate', [$account->seo]) . '" class="ui  horizontal green label no_underline">Update Manually</a>']);
             }
             $char = $account->destiny->firstCharacter();
             if ($char->updated_at->diffInMinutes() >= $this->refreshRateInMinutes) {
                 // update this
                 $this->dispatch(new UpdateAccount($account));
                 return response()->json(['updated' => true, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]);
             }
             return response()->json(['updated' => false, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]);
         } catch (ModelNotFoundException $e) {
             return response()->json(['error' => 'Gamertag not found']);
         }
     }
 }
 public function postGamertagOwnership(OwnershipFormRequest $request)
 {
     $account = Account::where('seo', Text::seoGamertag($request->request->get('gamertag')))->first();
     $this->user->account_id = $account->id;
     $this->user->save();
     return \Redirect::action('UserCpController@getIndex')->with('flash_message', ['header' => 'Gamertag Verified!', 'close' => true, 'body' => 'You have proved ownership of <strong>' . $account->gamertag . '</strong>.']);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('destiny_data', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('account_id', false, true);
         $table->string('membershipId', 64)->unique();
         $table->string('clanName', 32)->nullable();
         $table->string('clanTag', 6)->nullable();
         $table->mediumInteger('glimmer', false, true);
         $table->mediumInteger('grimoire', false, true);
         $table->mediumInteger('legendary_marks', false, true);
         $table->string('character_1', 32)->nullable();
         $table->string('character_2', 32)->nullable();
         $table->string('character_3', 32)->nullable();
         $table->tinyInteger('inactiveCounter', false, true);
         $table->timestamps();
     });
     \Onyx\Account::chunk(100, function ($accounts) {
         foreach ($accounts as $account) {
             $data = new \Onyx\Destiny\Objects\Data($account->toArray());
             $data->account_id = $account->id;
             $data->save();
         }
     });
 }
 public function getLightLeaderboard()
 {
     $pandas = Account::with('destiny.characters')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love')->where('clanTag', 'WRKD')->where('inactiveCounter', '<', 10);
     })->get();
     $p = [];
     Hashes::cacheAccountsHashes($pandas);
     foreach ($pandas as $panda) {
         $character = $panda->destiny->highestLevelHighestLight();
         $p[$character->level][] = ['name' => $panda->gamertag . " (" . $character->class->title . ")", 'maxLight' => $character->highest_light, 'light' => $character->light];
     }
     krsort($p);
     foreach ($p as $key => $value) {
         // lets sort the sub levels
         usort($value, function ($a, $b) {
             return $b['maxLight'] - $a['maxLight'];
         });
         $p[$key] = $value;
     }
     $msg = '<strong>Light Leaderboard</strong><br /><br />';
     foreach ($p as $level => $chars) {
         $msg .= "<strong>Level " . $level . "'s</strong><br />";
         $i = 1;
         foreach ($chars as $char) {
             $msg .= $i . ". " . $char['name'] . " <strong>" . $char['maxLight'] . "</strong><br />";
             $i++;
         }
         $msg .= '<br />';
     }
     return Response::json(['error' => false, 'msg' => $msg], 200);
 }
Beispiel #5
0
 public static function boot()
 {
     parent::boot();
     Account::deleting(function ($account) {
         Character::where('membershipId', $account->membershipId)->delete();
     });
 }
Beispiel #6
0
 public static function getAccountIdViaDestiny($membershipId)
 {
     $account = Account::where('destiny_membershipId', $membershipId)->first();
     if ($account instanceof Account) {
         return $account->id;
     }
     return null;
 }
 public function getIndex()
 {
     $accounts = Account::with('destiny.characters')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love');
     })->orderBy('gamertag', 'ASC')->paginate(15);
     // attempt hash cache
     Hashes::cacheAccountsHashes($accounts);
     return view('destiny.roster', ['members' => $accounts, 'description' => 'PandaLove Destiny Roster page', 'title' => 'PandaLove Destiny Roster']);
 }
 public function getIndex()
 {
     $accounts = Account::with('destiny', 'h5.playlists')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love');
     })->whereHas('h5', function ($query) {
         $query->where('totalKills', '!=', 0);
     })->orderBy('gamertag', 'ASC')->paginate(15);
     return view('halo5.roster', ['members' => $accounts, 'description' => 'PandaLove Halo 5 Roster page', 'title' => 'PandaLove Halo 5 Roster']);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('accounts', function (Blueprint $table) {
         $table->string('destiny_membershipId', 64);
         $table->dropIndex('accounts_id_index');
         $table->index('destiny_membershipId');
     });
     \Onyx\Account::chunk(100, function ($accounts) {
         foreach ($accounts as $account) {
             $data = \Onyx\Destiny\Objects\Data::where('account_id', $account->id)->first();
             $account->destiny_membershipId = $data->membershipId;
             $account->save();
         }
     });
 }
 public function manualUpdate($seo)
 {
     if (\Auth::check()) {
         try {
             $account = Account::with('h5.playlists.stock')->where('seo', $seo)->firstOrFail();
             $inactive = $account->h5->inactiveCounter;
             $this->dispatch(new UpdateHalo5Account($account));
             // reload account
             $account = Account::with('h5.playlists.stock')->where('seo', $seo)->firstOrFail();
             if ($account->h5->inactiveCounter > $inactive) {
                 // they manually refreshed a profile with no data changes. ugh
                 return redirect('h5/profile/' . $seo)->with('flash_message', ['close' => 'true', 'type' => 'yellow', 'header' => 'Uh oh', 'body' => 'No data changed! Please do not update accounts unless you know they are out of date.']);
             } else {
                 return redirect('h5/profile/' . $seo);
             }
         } catch (ModelNotFoundException $e) {
             \App::abort(404);
         }
     } else {
         return redirect('h5/profile/' . $seo)->with('flash_message', ['close' => 'true', 'type' => 'yellow', 'header' => 'Uh oh', 'body' => 'You must be signed in to manually update accounts']);
     }
 }
Beispiel #11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $pandas = Account::with('destiny.characters')->whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love')->where('inactiveCounter', '<=', 10);
     })->orderBy('gamertag', 'ASC')->get();
     foreach ($pandas as $panda) {
         $this->info('Processing ' . $panda->gamertag);
         // check for 10 inactive checks
         if ($panda->inactiveCounter >= $this->inactiveCounter) {
             $this->info('This account has not had new data in awhile.');
         }
         $char = $panda->destiny->firstCharacter();
         if ($char->updated_at->diffInMinutes() >= $this->refreshRateInMinutes) {
             // update this
             try {
                 $this->dispatch(new UpdateAccount($panda));
                 $this->info('Stats Updated!');
             } catch (HashNotLocatedException $e) {
                 $this->error('Could not find hash value: ' . $e->getMessage());
                 $this->info('Stat update has been skipped.');
             }
         }
     }
 }
Beispiel #12
0
 /**
  * @param $gamertag
  * @return \Onyx\Account|void
  */
 private function checkCacheForGamertag($gamertag)
 {
     $account = Account::where('seo', DestinyText::seoGamertag($gamertag))->first();
     if ($account instanceof Account) {
         return $account;
     }
     return false;
 }
Beispiel #13
0
 public function getWhoIsOn()
 {
     $accounts = Account::whereHas('destiny', function ($query) {
         $query->where('clanName', 'Panda Love');
     })->get();
     if (count($accounts) > 0) {
         $xboxclient = new XboxClient();
         $presence = $xboxclient->fetchAccountsPresence($accounts);
         $status = $xboxclient->prettifyOnlineStatus($presence, $accounts);
         return Response::json(['error' => false, 'msg' => $status]);
     } else {
         $this->_error('No Panda Love members were found');
     }
 }
Beispiel #14
0
 /**
  * @param $gamertag
  * @return mixed
  */
 private function getAccount($gamertag)
 {
     $lowercase = Text::seoGamertag($gamertag);
     return Account::where('seo', $lowercase)->first();
 }
Beispiel #15
0
 public function findAccountViaMembershipId($membershipId, $returnAccount = true)
 {
     foreach ($this->players as $player) {
         if ($player->membershipId == $membershipId) {
             if ($returnAccount == false) {
                 return $player;
             } else {
                 return $player->account;
             }
         }
     }
     return \Onyx\Account::where('destiny_membershipId', $membershipId)->first();
 }