diff --git a/eloquent-mutators.md b/eloquent-mutators.md index 6073156405d..e7c04709657 100644 --- a/eloquent-mutators.md +++ b/eloquent-mutators.md @@ -316,6 +316,8 @@ When casting to value objects, any changes made to the value object will automat $user->save(); +> {tip} If you plan to serialize your Eloquent models containing value objects to JSON or arrays, you should implement the `Illuminate\Contracts\Support\Arrayable` and `JsonSerializable` interfaces on the value object. + #### Inbound Casting Occasionally, you may need to write a custom cast that only transforms values that are being set on the model and does not perform any operations when attributes are being retrieved from the model. A classic example of an inbound only cast is a "hashing" cast. Inbound only custom casts should implement the `CastsInboundAttributes` interface, which only requires a `set` method to be defined.