BookStack\Http\Controllers\PageController::store PHP Method

store() public method

Store a new page by changing a draft into a page.
public store ( Illuminate\Http\Request $request, string $bookSlug, $pageId ) : Response
$request Illuminate\Http\Request
$bookSlug string
return Response
    public function store(Request $request, $bookSlug, $pageId)
    {
        $this->validate($request, ['name' => 'required|string|max:255']);
        $input = $request->all();
        $book = $this->bookRepo->getBySlug($bookSlug);
        $draftPage = $this->pageRepo->getById($pageId, true);
        $chapterId = intval($draftPage->chapter_id);
        $parent = $chapterId !== 0 ? $this->chapterRepo->getById($chapterId) : $book;
        $this->checkOwnablePermission('page-create', $parent);
        if ($parent->isA('chapter')) {
            $input['priority'] = $this->chapterRepo->getNewPriority($parent);
        } else {
            $input['priority'] = $this->bookRepo->getNewPriority($parent);
        }
        $page = $this->pageRepo->publishDraft($draftPage, $input);
        Activity::add($page, 'page_create', $book->id);
        return redirect($page->getUrl());
    }