sebdesign/laravel-state-machine

pass additional data when applying a transition

MartinP7r opened this issue · 3 comments

I was trying to figure out how to set variable data on the model when applying state changes.
E.g. within an application, a user can set the state of a certain model to scheduled and pass a date along with it. the date gets set in a different variable on the model, logic for that could be handled inside the callbacks, as long as there would be a way to pass more args with apply() (currently it seems like only object, event and a static string is possible?)

Hey,

After some thought I don't this it's possible to pass other data to callbacks.
But after checking symfony/workflow, they do allow passing a context array when applying transitions. I will try to implement that and I'll get back to you!

I've tagged v2.1.0 which allows to pass additional data when checking/applying transitions.

You can read more in the Context section of the README. Let me know if that is working well for you case!

Wow, thanks so much for the swift implementation!
I'll go check it out right away 🙂