refactor: Update image URL generation logic

- Refactored the logic for generating image URLs for champions and champion skins to improve readability and maintainability.
This commit is contained in:
Rico van Zelst
2024-05-01 01:12:31 +02:00
parent c1c876b488
commit c69a5472aa
2 changed files with 9 additions and 6 deletions

View File

@@ -101,9 +101,12 @@ class Champion extends Model
public function getChampionImageAttribute(bool $uncentered = false): string
{
$baseUrl = 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/';
$imagePath = $uncentered ? 'uncentered/' : '';
$imageUrl = $baseUrl.$imagePath.$this->champion_id.'/'.$this->champion_id.'000.jpg';
$baseUrl = 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/assets/characters/';
$championName = strtolower(str_replace([' ', "'", '.'], ['', '', ''], $this->name));
$imagePath = 'base/images/';
$imageUrl = $baseUrl . $championName . '/skins/' . $imagePath . $championName . '_splash_';
$imageUrl .= $uncentered ? 'uncentered' : 'centered';
$imageUrl .= '_0.jpg';
return $imageUrl;
}