feat: Add streamers to champion show view

- Added loading of streamers data in the champion show view.
- Updated ChampionController to load streamers for display.
This commit is contained in:
Rico van Zelst
2024-03-23 02:48:08 +01:00
parent b46128ec26
commit e6dcfacb31
10 changed files with 127 additions and 126 deletions

View File

@@ -24,22 +24,6 @@ class ChampionController extends Controller
return view('champions.index', ['champions' => $champions, 'roles' => $roles]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreChampionRequest $request)
{
//
}
/**
* Display the specified resource.
*/
@@ -47,41 +31,21 @@ class ChampionController extends Controller
{
$threeDaysInSeconds = 60 * 60 * 24 * 3;
$sixMonthsInSeconds = 60 * 60 * 24 * 30 * 6;
$tenMinutesInSeconds = 60 * 10;
$champion = Cache::remember('championShowCache'.$champion->slug, $threeDaysInSeconds, static fn () => $champion->load('skins', 'lanes'));
$champion = Cache::remember('championShowCache' . $champion->slug, $threeDaysInSeconds, static fn () => $champion->load('streamers', 'skins', 'lanes'));
//$streamers = Cache::remember('championStreamersCache' . $champion->slug, $tenMinutesInSeconds, static fn () => $champion->streamers);
$streamers = $champion->load('streamers')->streamers;
$splashColor = Cache::remember(
'championSplashColorCache'.$champion->slug,
'championSplashColorCache' . $champion->slug,
$sixMonthsInSeconds,
static fn () => getAverageColorFromImageUrl($champion->getChampionImageAttribute())
);
$champion->splash_color = $splashColor;
return view('champions.show', ['champion' => $champion]);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Champion $champion)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateChampionRequest $request, Champion $champion)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Champion $champion)
{
//
return view('champions.show', ['champion' => $champion, 'streamers' => $streamers]);
}
}