Replies: 1 comment
-
On a client app where a company manages contracts (alongside a lot more stuff), we went with the following approach. This project uses Filament and Spatie's event sourcing package. When a new contract is created on the admin, we halt Filament's default creation method and call our ContractAggregateRoot to fire a new ContractCreated event. We lock most fields on the contract edit page for direct changes. By doing this, we capture the "user intent", the reason they need to change something. So, for instance, if they need to change the contract duration, there's a button beside the duration field and a modal appears when clicked asking for the new date and the reason for this change. On submit we fire a "ContractDurationChanged" event. This is similar to what is described in this video: https://www.youtube.com/watch?v=DjZepWrAKzM&list=PLEG3qzgwkThvTIR--wvR4s-fjVdrKuDcK&index=3 |
Beta Was this translation helpful? Give feedback.
-
Hi,
I've been playing around with Verbs this morning by trying to build a demo-app an really like it. There is subject where I find it hard to figure out what the best practices are though.
Most apps I develop have parts that could greatly benefit from Event Sourcing and parts that are rather cruddy. The cruddy parts are ofter managed by a few administrators using a package like Laravel Nova or Fillament. The parts that would really benefit from event sourcing are often managed by end-users or API's.
For example, when building a course platform, tracking which lessons have been watched, is a great task for Event Sourcing. However, managing the lessons themselves will probably be done by a few administrators using an admin panel.
You could write custom events for all admin models. This feels like a lot extra boilerplate with complex admin-panels though. You probably need 3/4 extra files per model and all sorts of hacky hooks within an admin panel to get it to work.
Events:
LessonCreatedEvent
LessonUpdatedEvent
LessonDeletedEvent
States:
LessonState
Brent and Freek from Spatie wrote some interesting blog posts about this exact problem:
I was wondering if someone has any advice on how to tackle situations like this.
Beta Was this translation helpful? Give feedback.
All reactions