Skip to content

Commit

Permalink
fix: immunities / weaknesses not deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Jun 30, 2024
1 parent 53f6649 commit b44a328
Show file tree
Hide file tree
Showing 2 changed files with 1,166 additions and 808 deletions.
4 changes: 3 additions & 1 deletion app/Services/ElementService.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function updateElement($element, $data, $user) {
$element->update($data);

// create weaknesses and immunities
$element->weaknesses()->delete();
if (isset($data['weakness_id']) && $data['weakness_id']) {
foreach ($data['weakness_id'] as $key => $id) {
$weakness = ElementWeakness::where('element_id', $element->id)->where('weakness_id', $id)->first();
Expand All @@ -106,12 +107,13 @@ public function updateElement($element, $data, $user) {
ElementWeakness::create([
'element_id' => $element->id,
'weakness_id' => $id,
'multiplier' => $data['weakness_multiplier'][$key],
'multiplier' => $data['weakness_multiplier'][$key] ?? 1.1,
]);
}
}
}

$element->immunities()->delete();
if (isset($data['immunity_id']) && $data['immunity_id']) {
foreach ($data['immunity_id'] as $id) {
$immunity = ElementImmunity::where('element_id', $element->id)->where('immunity_id', $id)->first();
Expand Down
Loading

0 comments on commit b44a328

Please sign in to comment.