mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-23 01:12:47 +08:00
Added limit to books shown on homepage and make alphabetical
This commit is contained in:
parent
e5b9be2e76
commit
76eb8fc5d7
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
@include('books/list-item', ['book' => $book])
|
||||
<hr>
|
||||
@endforeach
|
||||
@if(count($books) === 10)
|
||||
<a href="/books">View all books »</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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user