Showing
3 changed files
with
6 additions
and
3 deletions
| ... | @@ -36,7 +36,7 @@ class HomeController extends Controller | ... | @@ -36,7 +36,7 @@ class HomeController extends Controller |
| 36 | */ | 36 | */ |
| 37 | public function index() | 37 | public function index() |
| 38 | { | 38 | { |
| 39 | - $books = $this->bookRepo->getAll(); | 39 | + $books = $this->bookRepo->getAll(10); |
| 40 | $activity = $this->activityService->latest(); | 40 | $activity = $this->activityService->latest(); |
| 41 | return view('home', ['books' => $books, 'activity' => $activity]); | 41 | return view('home', ['books' => $books, 'activity' => $activity]); |
| 42 | } | 42 | } | ... | ... |
| ... | @@ -25,9 +25,9 @@ class BookRepo | ... | @@ -25,9 +25,9 @@ class BookRepo |
| 25 | return $this->book->findOrFail($id); | 25 | return $this->book->findOrFail($id); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | - public function getAll() | 28 | + public function getAll($count = 10) |
| 29 | { | 29 | { |
| 30 | - return $this->book->all(); | 30 | + return $this->book->orderBy('name', 'asc')->take($count)->get(); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /** | 33 | /** | ... | ... |
| ... | @@ -11,6 +11,9 @@ | ... | @@ -11,6 +11,9 @@ |
| 11 | @include('books/list-item', ['book' => $book]) | 11 | @include('books/list-item', ['book' => $book]) |
| 12 | <hr> | 12 | <hr> |
| 13 | @endforeach | 13 | @endforeach |
| 14 | + @if(count($books) === 10) | ||
| 15 | + <a href="/books">View all books »</a> | ||
| 16 | + @endif | ||
| 14 | @else | 17 | @else |
| 15 | <p class="text-muted">No books have been created.</p> | 18 | <p class="text-muted">No books have been created.</p> |
| 16 | <a href="/books/create" class="text-pos"><i class="zmdi zmdi-edit"></i>Create one now</a> | 19 | <a href="/books/create" class="text-pos"><i class="zmdi zmdi-edit"></i>Create one now</a> | ... | ... |
-
Please register or sign in to post a comment