Showing
5 changed files
with
25 additions
and
3 deletions
| ... | @@ -91,9 +91,12 @@ class BookRepo | ... | @@ -91,9 +91,12 @@ class BookRepo |
| 91 | 91 | ||
| 92 | public function findSuitableSlug($name, $currentId = false) | 92 | public function findSuitableSlug($name, $currentId = false) |
| 93 | { | 93 | { |
| 94 | - $slug = Str::slug($name); | 94 | + $originalSlug = Str::slug($name); |
| 95 | + $slug = $originalSlug; | ||
| 96 | + $count = 2; | ||
| 95 | while($this->doesSlugExist($slug, $currentId)) { | 97 | while($this->doesSlugExist($slug, $currentId)) { |
| 96 | - $slug .= '-' . substr(md5(rand(1, 500)), 0, 3); | 98 | + $slug = $originalSlug . '-' . $count; |
| 99 | + $count++; | ||
| 97 | } | 100 | } |
| 98 | return $slug; | 101 | return $slug; |
| 99 | } | 102 | } | ... | ... |
| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | </div> | 12 | </div> |
| 13 | 13 | ||
| 14 | + @if(count($books) > 1) | ||
| 14 | <div class="col-md-4"> | 15 | <div class="col-md-4"> |
| 15 | <h3>Show Other Books</h3> | 16 | <h3>Show Other Books</h3> |
| 16 | @foreach($books as $otherBook) | 17 | @foreach($books as $otherBook) |
| ... | @@ -21,6 +22,7 @@ | ... | @@ -21,6 +22,7 @@ |
| 21 | @endif | 22 | @endif |
| 22 | @endforeach | 23 | @endforeach |
| 23 | </div> | 24 | </div> |
| 25 | + @endif | ||
| 24 | 26 | ||
| 25 | </div> | 27 | </div> |
| 26 | 28 | ... | ... |
resources/views/errors/404.blade.php
0 → 100644
| ... | @@ -37,7 +37,7 @@ | ... | @@ -37,7 +37,7 @@ |
| 37 | <div class="links text-center"> | 37 | <div class="links text-center"> |
| 38 | @yield('header-buttons') | 38 | @yield('header-buttons') |
| 39 | </div> | 39 | </div> |
| 40 | - @if($signedIn) | 40 | + @if(isset($signedIn) && $signedIn) |
| 41 | <img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}"> | 41 | <img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}"> |
| 42 | <div class="dropdown-container" data-dropdown> | 42 | <div class="dropdown-container" data-dropdown> |
| 43 | <span class="user-name" data-dropdown-toggle> | 43 | <span class="user-name" data-dropdown-toggle> | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | +use Illuminate\Support\Facades\DB; | ||
| 4 | + | ||
| 3 | class EntityTest extends TestCase | 5 | class EntityTest extends TestCase |
| 4 | { | 6 | { |
| 5 | 7 | ||
| ... | @@ -113,6 +115,12 @@ class EntityTest extends TestCase | ... | @@ -113,6 +115,12 @@ class EntityTest extends TestCase |
| 113 | ->seePageIs('/books/my-first-book') | 115 | ->seePageIs('/books/my-first-book') |
| 114 | ->see($book->name)->see($book->description); | 116 | ->see($book->name)->see($book->description); |
| 115 | 117 | ||
| 118 | + // Ensure duplicate names are given different slugs | ||
| 119 | + $this->asAdmin() | ||
| 120 | + ->visit('/books/create') | ||
| 121 | + ->submitForm('Save Book', $book->toArray()) | ||
| 122 | + ->seePageIs('/books/my-first-book-2'); | ||
| 123 | + | ||
| 116 | $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first(); | 124 | $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first(); |
| 117 | return $book; | 125 | return $book; |
| 118 | } | 126 | } | ... | ... |
-
Please register or sign in to post a comment