1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Accounted for non-existant entities

This commit is contained in:
Dan Brown
2015-12-28 17:19:23 +00:00
parent 6e75bcdc37
commit 05c4b2089c
4 changed files with 12 additions and 4 deletions

View File

@ -95,7 +95,9 @@ class BookRepo
*/
public function getBySlug($slug)
{
return $this->book->where('slug', '=', $slug)->first();
$book = $this->book->where('slug', '=', $slug)->first();
if ($book === null) abort(404);
return $book;
}
/**

View File

@ -56,7 +56,9 @@ class ChapterRepo
*/
public function getBySlug($slug, $bookId)
{
return $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
$chapter = $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
if ($chapter === null) abort(404);
return $chapter;
}
/**

View File

@ -64,7 +64,9 @@ class PageRepo
*/
public function getBySlug($slug, $bookId)
{
return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
$page = $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
if ($page === null) abort(404);
return $page;
}
/**