This pull request enables the use of spatie/data in conjunction with attribute casting.
Spatie's BaseData implements - like many other classes - Laravel's Arrayable Interface. This makes the toArray() method available, which can (and maybe should) be used instead of (array).
In this way, only the desired values of the attribute become part of the array instead of casting the internal structures as well.
This pull request enables the use of spatie/data in conjunction with attribute casting.
Spatie's BaseData implements - like many other classes - Laravel's Arrayable Interface. This makes the
toArray()
method available, which can (and maybe should) be used instead of(array)
. In this way, only the desired values of the attribute become part of the array instead of casting the internal structures as well.