Made new pages in chapters have a better inital priority

This commit is contained in:
Dan Brown
2016-04-07 19:03:00 +01:00
parent cbff2c6035
commit afc3583be8
2 changed files with 18 additions and 1 deletions

View File

@ -88,7 +88,6 @@ class PageController extends Controller
$input = $request->all();
$book = $this->bookRepo->getBySlug($bookSlug);
$input['priority'] = $this->bookRepo->getNewPriority($book);
$draftPage = $this->pageRepo->getById($pageId, true);
@ -96,6 +95,12 @@ class PageController extends Controller
$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);