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

createAsGuest() public method

Create a new page as a guest user.
public createAsGuest ( Illuminate\Http\Request $request, string $bookSlug, string | null $chapterSlug = null ) : mixed
$request Illuminate\Http\Request
$bookSlug string
$chapterSlug string | null
return mixed
    public function createAsGuest(Request $request, $bookSlug, $chapterSlug = null)
    {
        $this->validate($request, ['name' => 'required|string|max:255']);
        $book = $this->bookRepo->getBySlug($bookSlug);
        $chapter = $chapterSlug ? $this->chapterRepo->getBySlug($chapterSlug, $book->id) : null;
        $parent = $chapter ? $chapter : $book;
        $this->checkOwnablePermission('page-create', $parent);
        $page = $this->pageRepo->getDraftPage($book, $chapter);
        $this->pageRepo->publishDraft($page, ['name' => $request->get('name'), 'html' => '']);
        return redirect($page->getUrl('/edit'));
    }