/** * Saves the page and the fragment * * @return Response */ public function save(Request $request) { // get request data $email = $request->input('auth-email'); $id = $request->input('auth-id'); // get url & changes $url = $request->json()->get('url'); $changes = $request->json()->get('changes'); // get site and user $site = Site::getById($id); $user = User::getByEmail($email, $id); // remove site and .html from url $url = str_replace($id . '/', '', $url); $url = preg_replace('/\\.[^.\\s]{3,4}$/', '', $url); // edit the page $success = Page::edit($url, $changes, $site, $user); // show response if ($success == TRUE) { // re-publish plugins Publish::publishPlugins($user, $site); // re-publish site map Publish::publishSiteMap($user, $site); // return 200 return response('OK', 200); } else { return response('Page not found', 400); } }