mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: Add functionality to retrieve champion images from the database
- Added a new function `getChampionImage` to fetch champion images based on ID and type. - Created a new model `ChampionImage` to store champion image details in the database. - Implemented seeding of champion images using `ChampionImageSeeder`. - Updated usage of champion images in existing methods.
This commit is contained in:
@@ -101,19 +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/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;
|
||||
return getChampionImage($this->champion_id . '000', $uncentered ? 'uncentered_splash' : 'splash');
|
||||
}
|
||||
|
||||
public function getChampionImageTileAttribute(): string
|
||||
{
|
||||
return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-tiles/'.$this->champion_id.'/'.$this->champion_id.'000.jpg';
|
||||
return getChampionImage($this->champion_id . '000', 'tile');
|
||||
}
|
||||
|
||||
public function getChampionSquareImageAttribute(): string
|
||||
@@ -121,6 +114,7 @@ class Champion extends Model
|
||||
return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/'.$this->champion_id.'.png';
|
||||
}
|
||||
|
||||
// TODO: Implement Ability Icons in the DB and get them from there.
|
||||
public function getChampionAbilityIconQAttribute(): string
|
||||
{
|
||||
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/ability-icon/q';
|
||||
|
||||
23
app/Models/ChampionImage.php
Normal file
23
app/Models/ChampionImage.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ChampionImage extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'full_id',
|
||||
'champion_id',
|
||||
'type',
|
||||
'url',
|
||||
];
|
||||
|
||||
public function champion()
|
||||
{
|
||||
return $this->belongsTo(Champion::class);
|
||||
}
|
||||
}
|
||||
@@ -74,11 +74,7 @@ class ChampionSkin extends Model
|
||||
|
||||
public function getSkinImageAttribute(bool $uncentered = false): string
|
||||
{
|
||||
$championName = strtolower(str_replace([' ', "'"], ['', ''], $this->champion->name));
|
||||
$imagePath = $uncentered ? 'uncentered_' : 'centered_';
|
||||
$imageUrl = 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/assets/characters/'.$championName.'/skins/skin'.str_pad($this->skin_id, 2, '0', STR_PAD_LEFT).'/images/'.$championName.'_splash_'.$imagePath.$this->skin_id.'.jpg';
|
||||
|
||||
return $imageUrl;
|
||||
return getChampionImage($this->full_skin_id, $uncentered ? 'uncentered_splash' : 'splash');
|
||||
}
|
||||
|
||||
public function getSkinImageLoadingAttribute(): string
|
||||
|
||||
Reference in New Issue
Block a user