$this->checkOwnablePermission('chapter-create', $book);
$this->setPageTitle(trans('entities.chapters_create'));
return view('chapters/create', ['book' => $book, 'current' => $book]);
$this->checkOwnablePermission('chapter-create', $book);
$this->setPageTitle(trans('entities.chapters_create'));
return view('chapters/create', ['book' => $book, 'current' => $book]);
$this->checkOwnablePermission('chapter-create', $book);
$input = $request->all();
$this->checkOwnablePermission('chapter-create', $book);
$input = $request->all();
- $input['priority'] = $this->bookRepo->getNewPriority($book);
- $chapter = $this->chapterRepo->createFromInput($input, $book);
+ $input['priority'] = $this->entityRepo->getNewBookPriority($book);
+ $chapter = $this->entityRepo->createFromInput('chapter', $input, $book);
Activity::add($chapter, 'chapter_create', $book->id);
return redirect($chapter->getUrl());
}
Activity::add($chapter, 'chapter_create', $book->id);
return redirect($chapter->getUrl());
}
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->checkOwnablePermission('chapter-update', $chapter);
$this->setPageTitle(trans('entities.chapters_edit_named', ['chapterName' => $chapter->getShortName()]));
$this->checkOwnablePermission('chapter-update', $chapter);
$this->setPageTitle(trans('entities.chapters_edit_named', ['chapterName' => $chapter->getShortName()]));
- return view('chapters/edit', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
+ return view('chapters/edit', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->checkOwnablePermission('chapter-update', $chapter);
if ($chapter->name !== $request->get('name')) {
$this->checkOwnablePermission('chapter-update', $chapter);
if ($chapter->name !== $request->get('name')) {
- $chapter->slug = $this->chapterRepo->findSuitableSlug($request->get('name'), $book->id, $chapter->id);
+ $chapter->slug = $this->entityRepo->findSuitableSlug('chapter', $request->get('name'), $chapter->id, $chapter->book->id);
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->checkOwnablePermission('chapter-delete', $chapter);
$this->setPageTitle(trans('entities.chapters_delete_named', ['chapterName' => $chapter->getShortName()]));
$this->checkOwnablePermission('chapter-delete', $chapter);
$this->setPageTitle(trans('entities.chapters_delete_named', ['chapterName' => $chapter->getShortName()]));
- return view('chapters/delete', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
+ return view('chapters/delete', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
+ $book = $chapter->book;
$this->checkOwnablePermission('chapter-delete', $chapter);
Activity::addMessage('chapter_delete', $book->id, $chapter->name);
$this->checkOwnablePermission('chapter-delete', $chapter);
Activity::addMessage('chapter_delete', $book->id, $chapter->name);
* @throws \BookStack\Exceptions\NotFoundException
*/
public function showMove($bookSlug, $chapterSlug) {
* @throws \BookStack\Exceptions\NotFoundException
*/
public function showMove($bookSlug, $chapterSlug) {
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->setPageTitle(trans('entities.chapters_move_named', ['chapterName' => $chapter->getShortName()]));
$this->checkOwnablePermission('chapter-update', $chapter);
return view('chapters/move', [
'chapter' => $chapter,
$this->setPageTitle(trans('entities.chapters_move_named', ['chapterName' => $chapter->getShortName()]));
$this->checkOwnablePermission('chapter-update', $chapter);
return view('chapters/move', [
'chapter' => $chapter,
* @throws \BookStack\Exceptions\NotFoundException
*/
public function move($bookSlug, $chapterSlug, Request $request) {
* @throws \BookStack\Exceptions\NotFoundException
*/
public function move($bookSlug, $chapterSlug, Request $request) {
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->checkOwnablePermission('chapter-update', $chapter);
$entitySelection = $request->get('entity_selection', null);
$this->checkOwnablePermission('chapter-update', $chapter);
$entitySelection = $request->get('entity_selection', null);
- $this->chapterRepo->changeBook($parent->id, $chapter, true);
+ $this->entityRepo->changeBook('chapter', $parent->id, $chapter, true);
Activity::add($chapter, 'chapter_move', $chapter->book->id);
session()->flash('success', trans('entities.chapter_move_success', ['bookName' => $parent->name]));
Activity::add($chapter, 'chapter_move', $chapter->book->id);
session()->flash('success', trans('entities.chapter_move_success', ['bookName' => $parent->name]));
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$this->checkOwnablePermission('restrictions-manage', $chapter);
$roles = $this->userRepo->getRestrictableRoles();
return view('chapters/restrictions', [
$this->checkOwnablePermission('restrictions-manage', $chapter);
$roles = $this->userRepo->getRestrictableRoles();
return view('chapters/restrictions', [
- $book = $this->bookRepo->getBySlug($bookSlug);
- $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
session()->flash('success', trans('entities.chapters_permissions_success'));
return redirect($chapter->getUrl());
}
session()->flash('success', trans('entities.chapters_permissions_success'));
return redirect($chapter->getUrl());
}