Replies: 2 comments 2 replies
-
It seems I've done something similar but not read-only. Is it not just that aggregate uuid is expected in the constructor? I've had some success using an aggregate uuid set to null in the constructor signature than simply creating the uuid within the constructor, but then of course it's not quite as nice. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I use LaravelData for both events and commands (using the traits instead of extending Data) and I very much like your approach above. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying out an idea which makes use of
spatie/laravel-data
and this event-sourcing package where I was playing out with having the command class extending theData
class and act as arequest
in itself.Let's take as an example a command
CreatePerson
. Usually from the controller I generate aulid
string and assign it as thepersonId
within the command. Instead, this approach tries to leverage theSpatie\LaravelData\Attributes\Computed
attribute to generate and assign theulid
within the command itself.The problem arises when the same
computed
property is also assigned theAggregateUuid
attribute as it throws aSpatie\ EventSourcing \ AggregateRoots \ Exceptions \ MissingAggregateUuid
exception.I'm wondering if doing it this way is against how these two packages are meant to work together which is why I'm asking this here. Should this be acknowledged, I'm happy to contribute to a fix.
Beta Was this translation helpful? Give feedback.
All reactions