I want to join three tables: sections table: sectionid text formid
questions table: questionid question formid sectionid
options table: optionid option questionid
I want to fetch all sections where formid=x (for example) and questions related to sectionid and options related to questionid.
$data=Section::with('questions','options')
->where('formId',$formId)
->orderBy('sectionid')
->get()
->toJson();