public function post_save_settings()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         $page = new CmsPage();
         if (!empty($input['page_id'])) {
             $page = CmsPage::find($input['page_id']);
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         //VALIDATION CHECK
         $rules = array('page_name' => 'required|between:3,30|unique_lang:' . $input['page_id'] . ',' . $input['page_lang'] . ',pages,name', 'page_slug' => 'required|alpha_slug|unique_slug:pages,' . $input['page_lang'] . ',' . $input['page_parent_slug'] . ',' . $input['page_id'], 'page_owner' => 'not_in:0');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique_lang' => LL('cms::validation.unique', CMSLANG)->get(), 'unique_slug' => LL('cms::validation.unique_slug', CMSLANG)->get(), 'alpha_slug' => LL('cms::validation.alpha_slug', CMSLANG)->get(), 'not_in' => LL('cms::validation.not_in', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         //VALIDATION OK
         $page->author_id = AUTHORID;
         $page->lang = $input['page_lang'];
         $page->name = $input['page_name'];
         $page->parent_id = $input['page_parent'];
         $slug = (empty($input['page_parent_slug']) and empty($input['page_slug'])) ? '/' : str_replace('//', '/', $input['page_parent_slug'] . '/' . $input['page_slug']);
         $page->slug = $slug;
         //UPDATE ALL CHILD SLUGS
         CmsPage::update_child_slugs($input['page_id'], $input['page_parent_slug'], $input['page_slug']);
         $page->role_id = $input['page_owner'];
         $role = CmsRole::find($input['page_owner']);
         $page->role_level = $role->level;
         $page->access_level = $input['page_access'];
         $page->extra_id = $input['page_extra'];
         if (empty($input['page_id'])) {
             $page->order_id = Config::get('cms::settings.order');
         }
         $page->is_home = Input::has('is_home') ? 1 : 0;
         $page->is_valid = Input::has('is_valid') ? 1 : 0;
         //IF NEW PAGE, SAVE DEFAULT LAYOUT
         if (empty($input['page_id'])) {
             $page->template = 'default';
             $page->header = 'default';
             $page->layout = 'default';
             $page->footer = 'default';
         }
         $page->save();
         $pid = $page->id;
         if (CACHE) {
             Cache::forget('page_' . $pid . '_details');
         }
         //CHECK IS_HOME ALREADY PRESENT > DISABLE
         if (Input::has('is_home')) {
             DB::table('pages')->where('id', '<>', $pid)->where_is_home(1)->where_lang($input['page_lang'])->update(array('is_home' => 0));
         }
         $response = 'success';
         $msg = LL('cms::ajax_resp.page_settings_success', CMSLANG)->get();
         $backurl = $input['back_url'];
         $full_slug = URL::base() . $slug;
     } else {
         $pid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.page_settings_error', CMSLANG)->get();
         $backurl = '#';
         $full_slug = '';
     }
     $data = array('auth' => $auth, 'cls' => 'page_id', 'id' => $pid, 'pageid' => $pid, 'full_slug' => $full_slug, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }