setConnection('mysql')->hasOne(Account::class, 'id', 'account'); } public function homeBind($database) { return $this->setConnection($database)->hasOne(CharacterHomebind::class, 'guid', 'guid'); } public function spellColldown($database) { return $this->setConnection($database)->hasMany(CharacterSpellCooldown::class, 'guid', 'guid'); } public function canUnstuck($database) { if ($this->setConnection($database)->online == 1) { return "CHARACTER_ONLINE"; } if ($this->spellColldown($database)->get()) { foreach ($this->spellColldown($database)->get() as $spell) { if ($spell->spell == 8690) { return "HEARTHSTONE_CD"; } } } return "CAN_UNSTUCK"; } public function getUnstuckCdAttribute($database) { if ($this->canUnstuck($database) == "HEARTHSTONE_CD") { $spellCoolDown = CharacterSpellCooldown::on($database)->where('guid', $this->guid)->where('spell', 8690)->first(); return $spellCoolDown->time; } else { return 0; } } public function getImage($database) { $connection = $this->setConnection($database); $image = ''; switch ($connection->race) { case 1: $image = 'human'; break; case 2: $image = 'orc'; break; case 3: $image = 'dwarf'; break; case 4: $image = 'nightelf'; break; case 5: $image = 'undead'; break; case 6: $image = 'tauren'; break; case 7: $image = 'gnome'; break; case 8: $image = 'troll'; break; case 9: $image = 'goblin'; break; case 10: $image = 'highelf'; break; } $image .= ($connection->gender == 0) ? '-male' : '-female'; return $image; } public function glyphs($database) { $glyphs = [ 50004, 50000, 50008 ]; return $this->setConnection($database)->hasMany(CharacterSpell::class, 'guid', 'guid')->whereIn('spell', $glyphs)->where('active', 1); } }