From 144eb69cad245734610e0efb6341b0bade78cacc Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 29 Sep 2015 21:25:03 +0100 Subject: [PATCH] Added 404 page and extra tests --- app/Repos/BookRepo.php | 7 +++++-- resources/views/books/sort.blade.php | 22 ++++++++++++---------- resources/views/errors/404.blade.php | 9 +++++++++ resources/views/public.blade.php | 2 +- tests/EntityTest.php | 8 ++++++++ 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 resources/views/errors/404.blade.php diff --git a/app/Repos/BookRepo.php b/app/Repos/BookRepo.php index 9d37cf952..aacf96b06 100644 --- a/app/Repos/BookRepo.php +++ b/app/Repos/BookRepo.php @@ -91,9 +91,12 @@ class BookRepo public function findSuitableSlug($name, $currentId = false) { - $slug = Str::slug($name); + $originalSlug = Str::slug($name); + $slug = $originalSlug; + $count = 2; while($this->doesSlugExist($slug, $currentId)) { - $slug .= '-' . substr(md5(rand(1, 500)), 0, 3); + $slug = $originalSlug . '-' . $count; + $count++; } return $slug; } diff --git a/resources/views/books/sort.blade.php b/resources/views/books/sort.blade.php index f5c847fe2..e4e68d662 100644 --- a/resources/views/books/sort.blade.php +++ b/resources/views/books/sort.blade.php @@ -11,16 +11,18 @@ -
-

Show Other Books

- @foreach($books as $otherBook) - @if($otherBook->id !== $book->id) - - @endif - @endforeach -
+ @if(count($books) > 1) +
+

Show Other Books

+ @foreach($books as $otherBook) + @if($otherBook->id !== $book->id) + + @endif + @endforeach +
+ @endif diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php new file mode 100644 index 000000000..8f66e2d01 --- /dev/null +++ b/resources/views/errors/404.blade.php @@ -0,0 +1,9 @@ +@extends('public') + +@section('content') + + +

Page Not Found

+

The page you were looking for could not be found.

+ +@stop \ No newline at end of file diff --git a/resources/views/public.blade.php b/resources/views/public.blade.php index f252ce38c..73c8384fc 100644 --- a/resources/views/public.blade.php +++ b/resources/views/public.blade.php @@ -37,7 +37,7 @@ - @if($signedIn) + @if(isset($signedIn) && $signedIn) {{ $currentUser->name }}