route('content.overview') ->with('error', trans('admin/contents.invalidStatus')); } try { // try to find this page $page = Content::findOrFail($id); } catch (NotFoundHttpException $e) { // page not found return redirect() ->route('content.overview') ->with('error', trans('admin/contents.invalidPage')); } // try to change the page list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => $status]); // was something changed? if ($changedColumns == 0) { return redirect() ->route('content.edit', ['id' => $page->id]) ->with('error', trans('admin/contents.nothingToEdit')); } // fire events if ($status != Content::STATUS_DRAFT) { Event::fire(new PublishContent($page, $revision)); } else { Event::fire(new MakeDraftFromContent($page, $revision)); } // redirect back to overview with info for user return redirect() ->route('content.overview') ->with('success', trans('admin/contents.statusChanged')); } /** * Delete page * * @param $id * * @return \Illuminate\Http\RedirectResponse */ public function delete($id) { try { // try to find this page $page = Content::findOrFail($id); } catch (NotFoundHttpException $e) { // page not found return redirect() ->route('content.overview') ->with('error', trans('admin/contents.invalidPage')); } // change url to something unique $oldURL = $page->url; $page->url .= uniqid('_deleted_'); $page->save(); // delete page $page->delete(); // let module to delete some extra content created during page's life call_user_func([$page->module_handler, 'delete'], $page); // trigger delete event Event::fire(new DeleteContent($page)); // redirect back to overview with info for user return redirect() ->route('content.overview') ->with('success', trans('admin/contents.pageDeleted', [ 'name' => $page->title, 'url' => $oldURL ])); } /** * Sets page as homepage * * @param $id * * @return \Illuminate\Http\RedirectResponse */ public function setHomepage($id) { try { // try to find this page /** * @var $page Content */ $page = Content::findOrFail($id); } catch (NotFoundHttpException $e) { // page not found return redirect() ->back() ->with('error', trans('admin/contents.invalidPage')); } // disable any other existing homepage Content::where('is_homepage', 1) ->where('language', LaravelLocalization::getCurrentLocale()) ->update(['is_homepage' => 0]); // set new homepage list ($revision, $changedColumns) = $page->updateWithHistory(['is_homepage' => 'is_homepage'], ['is_homepage' => 1]); // was something changed? if ($changedColumns == 0) { return redirect() ->back() ->with('error', trans('admin/contents.nothingToEdit')); } // trigger delete event Event::fire(new SetHomepage($page, $revision)); // redirect back to overview with info for user return redirect() ->back() ->with('success', trans('admin/contents.homepageSetup', [ 'name' => $page->title, 'url' => $page->url ])); } }