I am in the process of building a new tool in my application (Laravel 10) that will allow my users to create contact/lead forms within the UI (Filament v3). When I started I thought it would be really simple, but I feel its getting more complicated and wonder if I am overcomplicating things.
The forms can be created as multi-step forms so the DB table looks a bit like below. So the Form is the parent of FormStep and is the parent of FormField. All of this is managed with a Livewire component and Blade file.
Firstly, I wonder if there is a better way to manage that structure. But more importantly, what is the best way to handle the responses? Originally I tried to save the parent Form info into a FormEntry model, with all the responses from the fields added into a JSON column of the FormEntry. But then I started to wonder what could be a better method to handle responses. Should I create a HasMany on the FormEntry and create a new model for FormEntryField ?
Any help/advice would be greatly appreciated. Many thanks in advance.
forms
- id
- name
- type
form_steps
- id
- form_id
- name
- sort_order
form_fields
- id
- form_step_id
- name
- type
- validation
- sort_order