@@ -37,7 +37,7 @@ public function __construct(
3737 */
3838 public function create (string $ bookSlug )
3939 {
40- $ book = $ this ->entityQueries ->books ->findVisibleBySlug ($ bookSlug );
40+ $ book = $ this ->entityQueries ->books ->findVisibleBySlugOrFail ($ bookSlug );
4141 $ this ->checkOwnablePermission ('chapter-create ' , $ book );
4242
4343 $ this ->setPageTitle (trans ('entities.chapters_create ' ));
@@ -62,7 +62,7 @@ public function store(Request $request, string $bookSlug)
6262 'default_template_id ' => ['nullable ' , 'integer ' ],
6363 ]);
6464
65- $ book = $ this ->entityQueries ->books ->findVisibleBySlug ($ bookSlug );
65+ $ book = $ this ->entityQueries ->books ->findVisibleBySlugOrFail ($ bookSlug );
6666 $ this ->checkOwnablePermission ('chapter-create ' , $ book );
6767
6868 $ chapter = $ this ->chapterRepo ->create ($ validated , $ book );
@@ -75,7 +75,7 @@ public function store(Request $request, string $bookSlug)
7575 */
7676 public function show (string $ bookSlug , string $ chapterSlug )
7777 {
78- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
78+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
7979 $ this ->checkOwnablePermission ('chapter-view ' , $ chapter );
8080
8181 $ sidebarTree = (new BookContents ($ chapter ->book ))->getTree ();
@@ -103,7 +103,7 @@ public function show(string $bookSlug, string $chapterSlug)
103103 */
104104 public function edit (string $ bookSlug , string $ chapterSlug )
105105 {
106- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
106+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
107107 $ this ->checkOwnablePermission ('chapter-update ' , $ chapter );
108108
109109 $ this ->setPageTitle (trans ('entities.chapters_edit_named ' , ['chapterName ' => $ chapter ->getShortName ()]));
@@ -125,7 +125,7 @@ public function update(Request $request, string $bookSlug, string $chapterSlug)
125125 'default_template_id ' => ['nullable ' , 'integer ' ],
126126 ]);
127127
128- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
128+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
129129 $ this ->checkOwnablePermission ('chapter-update ' , $ chapter );
130130
131131 $ this ->chapterRepo ->update ($ chapter , $ validated );
@@ -140,7 +140,7 @@ public function update(Request $request, string $bookSlug, string $chapterSlug)
140140 */
141141 public function showDelete (string $ bookSlug , string $ chapterSlug )
142142 {
143- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
143+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
144144 $ this ->checkOwnablePermission ('chapter-delete ' , $ chapter );
145145
146146 $ this ->setPageTitle (trans ('entities.chapters_delete_named ' , ['chapterName ' => $ chapter ->getShortName ()]));
@@ -156,7 +156,7 @@ public function showDelete(string $bookSlug, string $chapterSlug)
156156 */
157157 public function destroy (string $ bookSlug , string $ chapterSlug )
158158 {
159- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
159+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
160160 $ this ->checkOwnablePermission ('chapter-delete ' , $ chapter );
161161
162162 $ this ->chapterRepo ->destroy ($ chapter );
@@ -171,7 +171,7 @@ public function destroy(string $bookSlug, string $chapterSlug)
171171 */
172172 public function showMove (string $ bookSlug , string $ chapterSlug )
173173 {
174- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
174+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
175175 $ this ->setPageTitle (trans ('entities.chapters_move_named ' , ['chapterName ' => $ chapter ->getShortName ()]));
176176 $ this ->checkOwnablePermission ('chapter-update ' , $ chapter );
177177 $ this ->checkOwnablePermission ('chapter-delete ' , $ chapter );
@@ -189,7 +189,7 @@ public function showMove(string $bookSlug, string $chapterSlug)
189189 */
190190 public function move (Request $ request , string $ bookSlug , string $ chapterSlug )
191191 {
192- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
192+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
193193 $ this ->checkOwnablePermission ('chapter-update ' , $ chapter );
194194 $ this ->checkOwnablePermission ('chapter-delete ' , $ chapter );
195195
@@ -218,7 +218,7 @@ public function move(Request $request, string $bookSlug, string $chapterSlug)
218218 */
219219 public function showCopy (string $ bookSlug , string $ chapterSlug )
220220 {
221- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
221+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
222222 $ this ->checkOwnablePermission ('chapter-view ' , $ chapter );
223223
224224 session ()->flashInput (['name ' => $ chapter ->name ]);
@@ -237,7 +237,7 @@ public function showCopy(string $bookSlug, string $chapterSlug)
237237 */
238238 public function copy (Request $ request , Cloner $ cloner , string $ bookSlug , string $ chapterSlug )
239239 {
240- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
240+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
241241 $ this ->checkOwnablePermission ('chapter-view ' , $ chapter );
242242
243243 $ entitySelection = $ request ->get ('entity_selection ' ) ?: null ;
@@ -263,7 +263,7 @@ public function copy(Request $request, Cloner $cloner, string $bookSlug, string
263263 */
264264 public function convertToBook (HierarchyTransformer $ transformer , string $ bookSlug , string $ chapterSlug )
265265 {
266- $ chapter = $ this ->queries ->findVisibleBySlugs ($ bookSlug , $ chapterSlug );
266+ $ chapter = $ this ->queries ->findVisibleBySlugsOrFail ($ bookSlug , $ chapterSlug );
267267 $ this ->checkOwnablePermission ('chapter-update ' , $ chapter );
268268 $ this ->checkOwnablePermission ('chapter-delete ' , $ chapter );
269269 $ this ->checkPermission ('book-create-all ' );
0 commit comments