From 147e0078df9d3df772088d3b291a96a850566783 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Thu, 2 Nov 2023 12:36:54 +0100 Subject: [PATCH] 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 --- app/Models/ChampionRoles.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/Models/ChampionRoles.php b/app/Models/ChampionRoles.php index 0a84cee..7e8f8ec 100644 --- a/app/Models/ChampionRoles.php +++ b/app/Models/ChampionRoles.php @@ -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);