diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3f5d338de..d0eb16399 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -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]); } diff --git a/app/Repos/BookRepo.php b/app/Repos/BookRepo.php index c94817eb3..87309501e 100644 --- a/app/Repos/BookRepo.php +++ b/app/Repos/BookRepo.php @@ -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(); } /** diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 32bfbd028..2a97c4839 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -11,6 +11,9 @@ @include('books/list-item', ['book' => $book])
@endforeach + @if(count($books) === 10) + View all books » + @endif @else

No books have been created.

Create one now