/** * Run the Update * * @return mixed|void */ public function call() { $pheal = $this->setScope('char')->getPheal(); foreach ($this->api_info->characters as $character) { $result = $pheal->SkillQueue(['characterID' => $character->characterID]); // Skill Queues can change at anytime, so we // will clean up the current queue and re- // poulate it SkillQueueModel::where('characterID', $character->characterID)->delete(); $skill_queue = array_filter(array_map(function ($skill) use($character) { return ['characterID' => $character->characterID, 'queuePosition' => $skill->queuePosition, 'typeID' => $skill->typeID, 'level' => $skill->level, 'startSP' => $skill->startSP, 'endSP' => $skill->endSP, 'startTime' => $skill->startTime, 'endTime' => $skill->endTime, 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]; }, (array) $result->skillqueue)); // If there were any skills derived form the array_map // then we can bulk insert it into the table. if (count($skill_queue) > 0) { SkillQueueModel::insert($skill_queue); } } return; }
/** * Return a characters current Skill Queue * * @param $character_id * * @return mixed */ public function getCharacterSkilQueue($character_id) { return SkillQueue::join('invTypes', 'character_skill_queues.typeID', '=', 'invTypes.typeID')->where('characterID', $character_id)->orderBy('queuePosition')->get(); }