diff --git a/app/Http/Controllers/ChampionSkinController.php b/app/Http/Controllers/ChampionSkinController.php index 76310c3..4341ce9 100644 --- a/app/Http/Controllers/ChampionSkinController.php +++ b/app/Http/Controllers/ChampionSkinController.php @@ -51,7 +51,25 @@ class ChampionSkinController extends Controller */ public function show(ChampionSkin $championSkin) { - // + $skin = Cache::remember( + 'championSkinShowCache' . $championSkin->slug, + 60 * 60 * 8, + function () use ($championSkin) { + return $championSkin->load('champion', 'chromas'); + } + ); + + $splashColor = Cache::remember( + 'championSkinSplashColorCache' . $championSkin->slug, + 60 * 60 * 24, + function () use ($championSkin) { + return getAverageColorFromImageUrl($championSkin->getSkinImageAttribute()); + } + ); + + $skin->splash_color = $splashColor; + + return view('skins.show', compact('skin')); } /** diff --git a/app/Models/SkinChroma.php b/app/Models/SkinChroma.php index df24186..62c9d34 100644 --- a/app/Models/SkinChroma.php +++ b/app/Models/SkinChroma.php @@ -35,6 +35,11 @@ class SkinChroma extends Model public function skin(): BelongsTo { - return $this->belongsTo(Skin::class); + return $this->belongsTo(ChampionSkin::class, 'full_skin_id', 'full_skin_id'); + } + + public function getChromaImageAttribute() + { + return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-chroma-images/' . $this->skin->champion_id . '/' . $this->chroma_id . '.png'; } } diff --git a/app/View/Components/Skins/Grid_info.php b/app/View/Components/Skins/Grid_info.php new file mode 100644 index 0000000..91a37b5 --- /dev/null +++ b/app/View/Components/Skins/Grid_info.php @@ -0,0 +1,19 @@ + +
Heimerdinger Presents:
++ {{$skin->lore}} +
++ + {{$chroma->chroma_name}} + +
+More details
+ href="/skin/{{$skin->slug}}">More details