diff --git a/app/Services/CharacterManager.php b/app/Services/CharacterManager.php index ac0e07c5ef..e00babd6c8 100644 --- a/app/Services/CharacterManager.php +++ b/app/Services/CharacterManager.php @@ -137,9 +137,11 @@ public function createCharacter($data, $user, $isMyo = false) { } // Create character lineage - $lineage = $this->handleCharacterLineage($data, $character, $isMyo); - if (!$lineage) { - throw new \Exception('Error happened while trying to create lineage.'); + if (isset($data['parent_1_id']) || isset($data['parent_1_name']) || isset($data['parent_2_id']) || isset($data['parent_2_name'])) { + $lineage = $this->handleCharacterLineage($data, $character); + if (!$lineage) { + throw new \Exception('Error happened while trying to create lineage.'); + } } // Create character image @@ -2122,7 +2124,7 @@ public function updateCharacterLineage($data, $character, $user, $isAdmin = fals if(!$user->hasPower('manage_characters')) throw new \Exception('You do not have the required permissions to do this.'); if (!$character->lineage) { - return $this->handleCharacterLineage($data, $character, $character->is_myo_slot); + return $this->handleCharacterLineage($data, $character); } else { $character->lineage->update([ 'parent_1_id' => $data['parent_1_id'] ?? null, @@ -2149,10 +2151,14 @@ public function updateCharacterLineage($data, $character, $user, $isAdmin = fals * @param bool $isMyo * @return \App\Models\Character\CharacterLineage|bool */ - private function handleCharacterLineage($data, $character, $isMyo = false) + private function handleCharacterLineage($data, $character) { try { + if (!isset($data['parent_1_id']) && !isset($data['parent_1_name']) && !isset($data['parent_2_id']) && !isset($data['parent_2_name'])) { + throw new \Exception('No lineage data provided.'); + } + // check parent ids if set to see if character exists if (isset($data['parent_1_id']) && $data['parent_1_id']) { $parent_1 = Character::find($data['parent_1_id']); diff --git a/app/Services/Item/SlotService.php b/app/Services/Item/SlotService.php index 56dabb7373..3eb86cbb45 100644 --- a/app/Services/Item/SlotService.php +++ b/app/Services/Item/SlotService.php @@ -188,6 +188,9 @@ public function act($stacks, $user, $data) { if ($character = $charService->createCharacter($characterData, $user, true)) { flash('MYO slot created successfully.')->success(); } else { + foreach ($charService->errors()->getMessages()['error'] as $error) { + flash($error)->error(); + } throw new \Exception('Failed to use slot.'); } }