# Aero\\Common\\Traits\\CastsToJavaScript

This trait can be added to a model class. This trait provides a way of defining attributes that should be kept when casting to javascript. You can define these attributes in a protected **$castsToJs**array. The trait adds the following methods:

## static addCastToJs Method

This static method provides a way to dynamically add attributes to the models **$castsToJs**array. It expects you to pass the attribute key to be added.

## jsSerialize Method

This method returns the value of the **attributesToJs**method.

## toJavaScript Method

This method returns the JSON value of the **jsSerialize**method.

## attributesToJs Method

This method returns an array of the attributes that should be casted to javascript.

## getCastsToJs Method

This method returns the attribute keys that should be cast to javascript.