first(); $afterKeyword = str_replace('/lol-game-data/assets/ASSETS/Loadouts/SummonerEmotes', '', $emote['inventoryIcon']); $imageUrl = 'https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/assets/loadouts/summoneremotes' . strtolower($afterKeyword); $emoteAttributes = [ 'emote_id' => $emote['id'], 'title' => $emote['name'], 'image' => $imageUrl, ]; if ($emoteExists && $this->hasAttributesChanged($emoteExists, $emoteAttributes)) { Log::info('Emote ' . $emoteId . ' has changed, updating...'); $emoteExists->update($emoteAttributes); $changeCount++; } elseif (!$emoteExists) { Log::info('New emote detected! Creating ' . $emoteId . '...'); SummonerEmote::create($emoteAttributes); $changeCount++; } } if ($changeCount > 0) { Artisan::call('cloudflare:purge'); } } private function hasAttributesChanged($champion, $attributes): bool { foreach ($attributes as $key => $value) { if ($champion->{$key} != $value) { return true; } } return false; } }