+ public function findVisibleByIdOrFail(int $id): Page
+ {
+ $page = $this->findVisibleById($id);
+
+ if (is_null($page)) {
+ throw new NotFoundException(trans('errors.page_not_found'));
+ }
+
+ return $page;
+ }
+
+ public function findVisibleBySlugsOrFail(string $bookSlug, string $pageSlug): Page
+ {
+ /** @var ?Page $page */
+ $page = $this->start()->with('book')
+ ->scopes('visible')
+ ->whereHas('book', function (Builder $query) use ($bookSlug) {
+ $query->where('slug', '=', $bookSlug);
+ })
+ ->where('slug', '=', $pageSlug)
+ ->first();
+
+ if (is_null($page)) {
+ throw new NotFoundException(trans('errors.page_not_found'));
+ }
+
+ return $page;
+ }
+
+ public function usingSlugs(string $bookSlug, string $pageSlug): Builder
+ {
+ return $this->start()
+ ->where('slug', '=', $pageSlug)
+ ->whereHas('book', function (Builder $query) use ($bookSlug) {
+ $query->where('slug', '=', $bookSlug);
+ });
+ }
+