laravel-event-sourcing
laravel-event-sourcing copied to clipboard
Event properties matching ShouldBeStored methods are not serialized correctly
This is due to how Symfony serializer works. When the serialized object (event) contains a method with the name of the attribute, return value of that method is preferred and the value of the attribute is ignored.
The simplest example of this is declaring a Carbon property named createdAt
. When an event with this property is stored with a value different from now, the provided value is ignored and instead the event is saved in the database with the current time being the value of this property (which is the return value of the createdAt method on ShouldBeStored)