mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: skin grid info
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
19
app/View/Components/Skins/Grid_info.php
Normal file
19
app/View/Components/Skins/Grid_info.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Skins;
|
||||
|
||||
use App\Models\ChampionSkin;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Grid_info extends Component
|
||||
{
|
||||
public function __construct(public ChampionSkin $skin)
|
||||
{
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('components.skins.grid_info');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user