From 4d399f6ba77610635d4d1399b9ac3d5302c63b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Ren=C3=A9=20ROUET?= Date: Tue, 11 Jul 2023 13:28:20 +0200 Subject: [PATCH] add priority on page and chapter create --- app/Entities/Repos/ChapterRepo.php | 2 +- app/Entities/Repos/PageRepo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Entities/Repos/ChapterRepo.php b/app/Entities/Repos/ChapterRepo.php index 588854c7e..dadeec7f8 100644 --- a/app/Entities/Repos/ChapterRepo.php +++ b/app/Entities/Repos/ChapterRepo.php @@ -49,7 +49,7 @@ class ChapterRepo { $chapter = new Chapter(); $chapter->book_id = $parentBook->id; - $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1; + $chapter->priority = $chapter->priority ?: (new BookContents($parentBook))->getLastPriority() + 1; $this->baseRepo->create($chapter, $input); Activity::add(ActivityType::CHAPTER_CREATE, $chapter); diff --git a/app/Entities/Repos/PageRepo.php b/app/Entities/Repos/PageRepo.php index 521519dc0..637f4133a 100644 --- a/app/Entities/Repos/PageRepo.php +++ b/app/Entities/Repos/PageRepo.php @@ -164,7 +164,7 @@ class PageRepo $draft->draft = false; $draft->revision_count = 1; - $draft->priority = $this->getNewPriority($draft); + $draft->priority = $draft->priority ?: $this->getNewPriority($draft); $draft->save(); $this->revisionRepo->storeNewForPage($draft, trans('entities.pages_initial_revision'));