ChampionController handles HTTP requests for champion browsing and detail pages.
Overview
Located atsource/app/Http/Controllers/ChampionController.php, this controller:
- Displays paginated champion lists with role information
- Shows individual champion details with relationships
- Implements aggressive caching for performance
- Uses route model binding for clean URLs
Class Definition
Routes
Defined insource/routes/web.php:44-45:
Methods
index()
Displays a listing of all champions.Return Value
Rendered
champions.index Blade templateView Data
All champions ordered alphabetically by name
Champion role/lane assignments ordered by champion name
Cache Strategy
Results are cached for 8 hours using two separate cache keys:
championsListAllCache- Champion collectionchampionsRolesCache- Role assignments
Query Performance
- No eager loading on index page (to minimize payload size)
- Alphabetical sorting by champion name
- Returns all champions in a single query
Usage Example
Access the champion list at:show()
Displays a specific champion’s detail page.Parameters
Champion model instance (automatically resolved via route model binding)
Return Value
Rendered
champions.show Blade templateView Data
Champion model with eager-loaded relationships:
streamers- Associated Twitch streamersskins- All skins for this championlanes- Recommended lanes/roles
Collection of streamers who play this champion (extracted for convenience)
Cache Strategy
Each champion page is cached for 3 days (72 hours) with a unique cache key based on the champion’s slug.
championShowCache{slug}
Examples:
championShowCacheahrichampionShowCaseyasuochampionShowCaselee-sin
Route Model Binding
Laravel automatically resolves the{champion} route parameter:
Usage Example
Access a champion detail page:Eager Loading Strategy
Index Page (No Eager Loading)
The index page doesn’t eager load relationships to keep the payload small:Show Page (Aggressive Eager Loading)
The detail page loads all necessary relationships upfront:streamers
streamers
Type:
HasManyTwitch streamers associated with this championskins
skins
Type:
HasManyAll skins available for this championlanes
lanes
Type:
HasManyRecommended lanes and roles for this championCache Invalidation
The controller doesn’t automatically invalidate cache when champion data changes. Manual cache clearing may be needed after data updates:Performance Considerations
8-Hour Index Cache
Champion list rarely changes, so 8-hour cache is appropriate
3-Day Detail Cache
Individual champions change even less frequently
Eager Loading
Prevents N+1 queries on detail pages
Route Model Binding
Automatic model resolution keeps controllers clean
Related Documentation
Champion Model
View the Champion model API reference
Champion Feature
Learn about the champion browsing feature
Architecture
Understand the MVC architecture
Data Sources
Learn where champion data comes from