first(); $chromaAttributes = [ 'chroma_id' => $chromaId, 'full_skin_id' => $skin['id'], 'skin_name' => $skin['name'] . ' ' . $champion['name'], 'chroma_name' => $chroma['name'], 'chroma_colors' => $chroma['colors'], 'chroma_image' => $chroma['chromaPath'], ]; // Mundo is a special case, his skins often include his name in the skin name, so we need to remove it. if (str_contains($chromaAttributes['skin_name'], 'Mundo Dr. Mundo')) { $chromaAttributes['skin_name'] = str_replace( 'Mundo Dr. Mundo', 'Mundo', $chromaAttributes['skin_name'] ); } if ($chromaExists && $this->hasAttributesChanged($chromaExists, $chromaAttributes)) { Log::info('Updating chroma: ' . $chromaId); $chromaExists->update($chromaAttributes); } elseif (!$chromaExists) { Log::info('Creating chroma: ' . $chromaId); SkinChroma::create($chromaAttributes); } } } } } private function hasAttributesChanged($chroma, $attributes): bool { foreach ($attributes as $key => $value) { if ($chroma->{$key} != $value) { return true; } } return false; } }