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:
Rico van Zelst
2024-05-02 00:50:51 +02:00
parent 80fc3200c6
commit 6d2731f1d3
8 changed files with 138 additions and 18 deletions

View File

@@ -2,6 +2,7 @@
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;
use App\Models\ChampionImage;
function getRoleIcon($roleName): string
{
@@ -64,3 +65,21 @@ function getRoleIconSvg($roleName): string
return $roleIcons[$roleName];
}
/**
* Get the champion image
*
* @param string $full_id
* @param enum $type splash, uncentered_splash, loading, tile, icon, ability, video
* @return string
*/
function getChampionImage($full_id, $type): string
{
$championImage = ChampionImage::where('full_id', $full_id)->where('type', $type)->first();
if (!$championImage) {
return '';
}
return $championImage->url;
}