ChampionSkinController handles HTTP requests for the skin catalog with advanced filtering and pagination.
Overview
Located atsource/app/Http/Controllers/ChampionSkinController.php, this controller:
- Displays paginated skin catalog (16 skins per page)
- Implements search by skin name
- Filters by rarity tier
- Supports HTMX for dynamic updates
- Shows individual skin details with chromas
- Uses 48-hour caching on detail pages
Class Definition
Routes
Defined insource/routes/web.php:47-48:
Methods
index()
Displays a filterable, paginated listing of skins.Parameters
HTTP request object containing query parameters and headers
Query Parameters
Partial match search on
skin_name columnExample: ?filter[name]=star matches “Star Guardian Ahri”Exact match on
rarity columnValid values: Common, Rare, Epic, Legendary, Mythic, Ultimate, Transcendent, ExaltedExample: ?filter[rarity]=LegendaryPage number for pagination (16 skins per page)Example:
?page=2Return Value
Rendered
skins.index Blade template (or skin-list fragment for HTMX requests)View Data
Paginated collection of skins (16 per page) with query string preservation
Mapping of rarity tiers to TailwindCSS color classes
Rarity Color Mapping
HTMX Support
When the request contains the
HX-Request header (indicating an HTMX request), only the skin-list Blade fragment is rendered instead of the full page.- Faster partial page updates
- Reduced bandwidth usage
- Smoother user experience for filtering/pagination
Usage Examples
show()
Displays a specific skin’s detail page with chromas.Parameters
ChampionSkin model instance (automatically resolved via route model binding)
Return Value
Rendered
skins.show Blade templateView Data
Skin model with eager-loaded relationships:
champion- Parent championchromas- All chroma variants for this skin
Cache Strategy
Each skin page is cached for 48 hours with a unique cache key based on the skin’s slug.
championSkinShowCache{slug}
Examples:
championSkinShowCasestar-guardian-ahrichampionSkinShowCaseproject-vaynechampionSkinShowCasespirit-blossom-yasuo
Eager Loading
champion
champion
Type:
BelongsToThe parent champion for this skinchromas
chromas
Type:
HasManyAll chroma color variants for this skinUsage Example
Spatie Query Builder
This controller uses Spatie Query Builder for filtering:Allowed Filters
name (partial match)
name (partial match)
Column:
skin_nameType: Partial match (LIKE query)Example: ?filter[name]=dragon matches:- “Dragon Trainer Tristana”
- “Dragonslayer Vayne”
- “Dragon Fist Lee Sin”
rarity (exact match)
rarity (exact match)
Column:
rarityType: Exact matchExample: ?filter[rarity]=Mythic matches only Mythic rarity skinsQuery String Preservation
This ensures pagination links preserve filter parameters. Clicking “Next Page” maintains your search/filter state.
Pagination
Number of skins displayed per page
CRUD Methods (Unused)
The controller includes standard CRUD method stubs but they’re not implemented:Skin data is managed through Artisan commands and data imports, not through web CRUD interfaces.
Performance Considerations
Indexed Queries
Ensure
skin_name and rarity columns are indexed for fast filtering48-Hour Cache
Individual skin pages cached for 2 days
Pagination
Limits query size to 16 rows per request
Fragment Rendering
HTMX requests return only the updated fragment
Related Documentation
Skin Model
View the ChampionSkin model API reference
Skin Feature
Learn about the skin catalog feature
Champion Model
View the parent Champion model
Architecture
Understand the MVC architecture