'array', ]; public function champion(): BelongsTo { return $this->belongsTo(Champion::class, 'champion_id', 'champion_id'); } public function getRolesAttribute($value): array { $value = json_decode($value); $roleNames = [ 'TOP' => 'Toplane', 'JUNGLE' => 'Jungle', 'MIDDLE' => 'Midlane', 'BOTTOM' => 'Botlane', 'UTILITY' => 'Support', ]; $transformedRoles = []; foreach ($value as $role) { if (isset($roleNames[$role])) { $transformedRoles[] = $roleNames[$role]; } } return $transformedRoles; } public function getRoleIcon($roleName) { $roleIcons = [ 'Toplane' => 'gm-top.png', 'Jungle' => 'gm-jungle.png', 'Midlane' => 'gm-mid.png', 'Botlane' => 'gm-bot.png', 'Support' => 'gm-support.png', ]; return asset('img/' . $roleIcons[$roleName]); } }