Dan Brown

Accounted for non-existant entities

...@@ -95,7 +95,9 @@ class BookRepo ...@@ -95,7 +95,9 @@ class BookRepo
95 */ 95 */
96 public function getBySlug($slug) 96 public function getBySlug($slug)
97 { 97 {
98 - return $this->book->where('slug', '=', $slug)->first(); 98 + $book = $this->book->where('slug', '=', $slug)->first();
99 + if ($book === null) abort(404);
100 + return $book;
99 } 101 }
100 102
101 /** 103 /**
......
...@@ -56,7 +56,9 @@ class ChapterRepo ...@@ -56,7 +56,9 @@ class ChapterRepo
56 */ 56 */
57 public function getBySlug($slug, $bookId) 57 public function getBySlug($slug, $bookId)
58 { 58 {
59 - return $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first(); 59 + $chapter = $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
60 + if ($chapter === null) abort(404);
61 + return $chapter;
60 } 62 }
61 63
62 /** 64 /**
......
...@@ -64,7 +64,9 @@ class PageRepo ...@@ -64,7 +64,9 @@ class PageRepo
64 */ 64 */
65 public function getBySlug($slug, $bookId) 65 public function getBySlug($slug, $bookId)
66 { 66 {
67 - return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first(); 67 + $page = $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
68 + if ($page === null) abort(404);
69 + return $page;
68 } 70 }
69 71
70 /** 72 /**
......
1 -@extends('public') 1 +@extends('base')
2 2
3 @section('content') 3 @section('content')
4 4
5 5
6 +<div class="container">
6 <h1>Page Not Found</h1> 7 <h1>Page Not Found</h1>
7 <p>The page you were looking for could not be found.</p> 8 <p>The page you were looking for could not be found.</p>
9 +</div>
8 10
9 @stop 11 @stop
...\ No newline at end of file ...\ No newline at end of file
......