Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-11-09 20:39:06 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
76eb8fc5d7ae739d880e7305aa5593aa11424e54
76eb8fc5
1 parent
e5b9be2e
Added limit to books shown on homepage and make alphabetical
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
3 deletions
app/Http/Controllers/HomeController.php
app/Repos/BookRepo.php
resources/views/home.blade.php
app/Http/Controllers/HomeController.php
View file @
76eb8fc
...
...
@@ -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
]);
}
...
...
app/Repos/BookRepo.php
View file @
76eb8fc
...
...
@@ -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
();
}
/**
...
...
resources/views/home.blade.php
View file @
76eb8fc
...
...
@@ -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>
...
...
Please
register
or
sign in
to post a comment