]> BookStack Code Mirror - bookstack/commitdiff
Accounted for non-existant entities
authorDan Brown <redacted>
Mon, 28 Dec 2015 17:19:23 +0000 (17:19 +0000)
committerDan Brown <redacted>
Mon, 28 Dec 2015 17:19:23 +0000 (17:19 +0000)
app/Repos/BookRepo.php
app/Repos/ChapterRepo.php
app/Repos/PageRepo.php
resources/views/errors/404.blade.php

index 469fdb31d053a5beec221d91fd6dc50c20850a4e..031e3b44c18d6b708108c9f2a3bf66ee08f4cf6a 100644 (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;
     }
 
     /**
index c3d75ca9d8a829b001a50af6874994988f9c5f7c..1e4996a407c3c50a4e17e546c25979273e5dc4cd 100644 (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;
     }
 
     /**
index 052d9dd1e9abe56fca9178dbfec5f536d61d554a..e049ae57b67a6cde77d18d07683f349f5891e817 100644 (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;
     }
 
     /**
index 8f66e2d0152047e6bc7ad68c99fc16f12ecdddd3..0062bb25895ca9f276c3fd9ba89e4657d9a2917b 100644 (file)
@@ -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