BookStack\Http\Controllers\PageController::move PHP Метод

move() публичный Метод

Does the action of moving the location of a page
public move ( string $bookSlug, string $pageSlug, Illuminate\Http\Request $request ) : mixed
$bookSlug string
$pageSlug string
$request Illuminate\Http\Request
Результат mixed
    public function move($bookSlug, $pageSlug, Request $request)
    {
        $book = $this->bookRepo->getBySlug($bookSlug);
        $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
        $this->checkOwnablePermission('page-update', $page);
        $entitySelection = $request->get('entity_selection', null);
        if ($entitySelection === null || $entitySelection === '') {
            return redirect($page->getUrl());
        }
        $stringExploded = explode(':', $entitySelection);
        $entityType = $stringExploded[0];
        $entityId = intval($stringExploded[1]);
        $parent = false;
        if ($entityType == 'chapter') {
            $parent = $this->chapterRepo->getById($entityId);
        } else {
            if ($entityType == 'book') {
                $parent = $this->bookRepo->getById($entityId);
            }
        }
        if ($parent === false || $parent === null) {
            session()->flash('The selected Book or Chapter was not found');
            return redirect()->back();
        }
        $this->pageRepo->changePageParent($page, $parent);
        Activity::add($page, 'page_move', $page->book->id);
        session()->flash('success', sprintf('Page moved to "%s"', $parent->name));
        return redirect($page->getUrl());
    }