use Activity;
+use BookStack\Exceptions\NotFoundException;
use BookStack\Services\RestrictionService;
use Illuminate\Support\Str;
use BookStack\Chapter;
* @param $slug
* @param $bookId
* @return mixed
+ * @throws NotFoundException
*/
public function getBySlug($slug, $bookId)
{
$chapter = $this->chapterQuery()->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
- if ($chapter === null) abort(404);
+ if ($chapter === null) throw new NotFoundException('Chapter not found');
return $chapter;
}
+ /**
+ * Get the child items for a chapter
+ * @param Chapter $chapter
+ */
+ public function getChildren(Chapter $chapter)
+ {
+ return $this->restrictionService->enforcePageRestrictions($chapter->pages())->get();
+ }
+
/**
* Create a new chapter from request input.
* @param $input
}
Activity::removeEntity($chapter);
$chapter->views()->delete();
+ $chapter->restrictions()->delete();
$chapter->delete();
}