NOW MANAGED ON CODEBERG
Accounted for non-existant entities
Dan Brown05c4b2089c47
diff --git a/app/Repos/BookRepo.php b/app/Repos/BookRepo.phpindex 469fdb31d..031e3b44c 100644--- a/app/Repos/BookRepo.php+++ b/app/Repos/BookRepo.php@@ -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;}/**diff --git a/app/Repos/ChapterRepo.php b/app/Repos/ChapterRepo.phpindex c3d75ca9d..1e4996a40 100644--- a/app/Repos/ChapterRepo.php+++ b/app/Repos/ChapterRepo.php@@ -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;}/**diff --git a/app/Repos/PageRepo.php b/app/Repos/PageRepo.phpindex 052d9dd1e..e049ae57b 100644--- a/app/Repos/PageRepo.php+++ b/app/Repos/PageRepo.php@@ -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;}/**diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.phpindex 8f66e2d01..0062bb258 100644--- a/resources/views/errors/404.blade.php+++ b/resources/views/errors/404.blade.php@@ -1,9 +1,11 @@-@extends('public')+@extends('base')@section('content')+<div class="container"><h1>Page Not Found</h1><p>The page you were looking for could not be found.</p>+</div>@stop\ No newline at end of file