]> BookStack Code Mirror - bookstack/commitdiff
Added limit to books shown on homepage and make alphabetical
authorDan Brown <redacted>
Mon, 9 Nov 2015 20:39:06 +0000 (20:39 +0000)
committerDan Brown <redacted>
Mon, 9 Nov 2015 20:39:06 +0000 (20:39 +0000)
app/Http/Controllers/HomeController.php
app/Repos/BookRepo.php
resources/views/home.blade.php

index 3f5d338de2842d670209c36afee456da499994f6..d0eb163996e79d423c587b146ff90575127dcad8 100644 (file)
@@ -36,7 +36,7 @@ class HomeController extends Controller
      */
     public function index()
     {
-        $books = $this->bookRepo->getAll();
+        $books = $this->bookRepo->getAll(10);
         $activity = $this->activityService->latest();
         return view('home', ['books' => $books, 'activity' => $activity]);
     }
index c94817eb328c721558501827a002375337b2eee0..87309501e595a06af5f726f9f2936fce9d99c880 100644 (file)
@@ -25,9 +25,9 @@ class BookRepo
         return $this->book->findOrFail($id);
     }
 
-    public function getAll()
+    public function getAll($count = 10)
     {
-        return $this->book->all();
+        return $this->book->orderBy('name', 'asc')->take($count)->get();
     }
 
     /**
index 32bfbd028e14d66852729c8bbd64bceb4ead1e1b..2a97c4839c13fd0d1d30ffe1e615a361c4c10c96 100644 (file)
@@ -11,6 +11,9 @@
                         @include('books/list-item', ['book' => $book])
                         <hr>
                     @endforeach
+                    @if(count($books) === 10)
+                            <a href="/books">View all books &raquo;</a>
+                    @endif
                 @else
                     <p class="text-muted">No books have been created.</p>
                     <a href="/books/create" class="text-pos"><i class="zmdi zmdi-edit"></i>Create one now</a>