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;
}
</div>
- <div class="col-md-4">
- <h3>Show Other Books</h3>
- @foreach($books as $otherBook)
- @if($otherBook->id !== $book->id)
- <div id="additional-books">
- <a href="/books/{{ $otherBook->slug }}/sort-item" class="text-book"><i class="zmdi zmdi-book"></i>{{ $otherBook->name }}</a>
- </div>
- @endif
- @endforeach
- </div>
+ @if(count($books) > 1)
+ <div class="col-md-4">
+ <h3>Show Other Books</h3>
+ @foreach($books as $otherBook)
+ @if($otherBook->id !== $book->id)
+ <div id="additional-books">
+ <a href="/books/{{ $otherBook->slug }}/sort-item" class="text-book"><i class="zmdi zmdi-book"></i>{{ $otherBook->name }}</a>
+ </div>
+ @endif
+ @endforeach
+ </div>
+ @endif
</div>
--- /dev/null
+@extends('public')
+
+@section('content')
+
+
+ <h1>Page Not Found</h1>
+ <p>The page you were looking for could not be found.</p>
+
+@stop
\ No newline at end of file
<div class="links text-center">
@yield('header-buttons')
</div>
- @if($signedIn)
+ @if(isset($signedIn) && $signedIn)
<img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}">
<div class="dropdown-container" data-dropdown>
<span class="user-name" data-dropdown-toggle>
<?php
+use Illuminate\Support\Facades\DB;
+
class EntityTest extends TestCase
{
->seePageIs('/books/my-first-book')
->see($book->name)->see($book->description);
+ // Ensure duplicate names are given different slugs
+ $this->asAdmin()
+ ->visit('/books/create')
+ ->submitForm('Save Book', $book->toArray())
+ ->seePageIs('/books/my-first-book-2');
+
$book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
return $book;
}