/** * Loop through the Layouts, Elements and Messages in order to create an nested JSON structure which contains all the information. * * @param \Element ID */ public function getLayoutsJSON2() { $layoutsdata = Layout::with('Elements.Messages')->get(); return Response::json(array('Layouts' => $layoutsdata)); }