feat: role mapping to popular naming

While the database values match the ones internally used by Riot Games in the League of Legends client, this is not how most people call them. So we map them to the way people call them for SEO
This commit is contained in:
Rico van Zelst
2023-11-02 12:36:54 +01:00
parent 6904eb4ca4
commit 147e0078df

View File

@@ -19,6 +19,35 @@ class ChampionRoles extends Model
'roles' => 'array',
];
public function getRolesAttribute($value)
{
$mappedRoles = [];
foreach ($value as $role) {
switch ($role) {
case 'TOP':
$mappedRoles[] = 'Toplane';
break;
case 'JUNGLE':
$mappedRoles[] = 'Jungle';
break;
case 'MIDDLE':
$mappedRoles[] = 'Midlane';
break;
case 'BOTTOM':
$mappedRoles[] = 'Botlane';
break;
case 'UTILITY':
$mappedRoles[] = 'Support';
break;
default:
break;
}
}
return $mappedRoles;
}
public function champion()
{
return $this->belongsTo(Champion::class);