4 years ago

Multi-step setup/form and middleware

Posted 4 years ago by cbojer


I'm building an app, where we have a setup wizard, that helps us get our users filling out the different information that is needed before they can start using the site. In this setup, there is 5 different steps that they need to complete. They cannot use the app, before they have completed these 5 steps, so I've of course set middleware up that checks whether the setup has been completed.

The problem, however, is if users were to not complete the setup(as will probably happen from time to time). In this case, I would need to redirect them back to the first uncompleted step in the setup. My first idea of getting this done, was to create a middleware implementation for each step in the form, that will check whether the step was completed by querying the model and/or its relations(this feels bad!), and if it was, then check for all the subsequent steps, until you find a step, that hasn't been completed and then redirect them there, but I can't help but feel like I'm overcomplicating it here or not doing it gracefully.

How would you attack the problem? Another solution I've fiddled with was creating a setup table, that links to the model and keeps track of the last completed step, but I can't really decide whether this is any better.

Thanks in advance, Casper

Please sign in or create an account to participate in this conversation.