laravel-arcanist / arcanist

🧙‍♀️ Arcanist takes the pain out of building multi-step form wizards in Laravel.
https://laravel-arcanist.com
MIT License
405 stars 33 forks source link

Actions in steps #13

Closed rabol closed 3 years ago

rabol commented 3 years ago

Hi

I'm trying to make a new registration Wizard, but I don't want to create user, subscriptions etc. unless the email address is validated, so I was wondering if it is possible to some how send a notification email to the email entered in step 1, then in step two, ask for the verification code and not allow step 3 until the code is received ?

I was hoping to do this via events, but I'm not sure if there a 'Step started event' and the documentation on events is not yet complete :)

ksassnowski commented 3 years ago

Hi!

You could probably do this by overriding the handle method on a step. This method gets called after the request payload was validated. In there, you can basically do whatever you want (like sending a notification or checking if the entered code is valid). This method needs to return a StepResult which indicates if the step was successful or not. The default implementation simply returns a successful response:

https://github.com/laravel-arcanist/arcanist/blob/14bd127dc745bdf285d4c6a8ea665123046743cd/src/WizardStep.php#L86