belongsTo(Champion::class, 'champion_id', 'champion_id'); } public function getRolesAttribute($value): array { $value = json_decode((string) $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; } protected function casts(): array { return [ 'roles' => 'array', ]; } }