public function getPage($position = '') { if (Request::isMethod('post')) { // $data = Request::get('data'); $position = Request::get('position'); foreach ($data as $key => $val) { $page = Page::find($val['id']); $page->page_order = $key; !isset($val['children']) ? $page->page_parent = 0 : ''; $page->save(); if (isset($val['children'])) { foreach ($val['children'] as $childkey => $childval) { $child = Page::find($childval['id']); $child->page_parent = $val['id']; $child->page_order = $childkey; $child->save(); } } } return response()->json(['success' => TRUE]); } $this->data['pages'] = Page::getNested($position); return view('backend.page.lists', $this->data); }