BookStack\Repos\PageRepo::findPageUsingOldSlug PHP Method

findPageUsingOldSlug() public method

Search through page revisions and retrieve the last page in the current book that has a slug equal to the one given.
public findPageUsingOldSlug ( $pageSlug, $bookSlug ) : null | Page
$pageSlug
$bookSlug
return null | BookStack\Page | Page
    public function findPageUsingOldSlug($pageSlug, $bookSlug)
    {
        $revision = $this->pageRevision->where('slug', '=', $pageSlug)->whereHas('page', function ($query) {
            $this->permissionService->enforcePageRestrictions($query);
        })->where('type', '=', 'version')->where('book_slug', '=', $bookSlug)->orderBy('created_at', 'desc')->with('page')->first();
        return $revision !== null ? $revision->page : null;
    }