Improve the book listing...

Add order_by.  Prefetch author and show author's name.  Add table
markup.
This commit is contained in:
barnold 2022-09-17 16:20:30 +01:00
parent 143dcc9bdc
commit 8dcdb9fb10
2 changed files with 14 additions and 2 deletions

View File

@ -12,7 +12,11 @@ sub count_all ($self) {
sub get_page ($self, $page_number = 1) {
my $rs = $self->schema->resultset('Book')->search_rs(
undef,
{ page => $page_number, rows => 10 },
{ prefetch => [ "author" ],
order_by => [ "me.name " ],
page => $page_number,
rows => 10,
},
);
return $rs;
}

View File

@ -6,9 +6,17 @@ Book count is <%= $book_count %>.
<p/>
<div>
<table>
<tr>
<th>Book</th><th>Author</th>
</tr>
% for my $book ($book_page->all) {
<%= $book->name %><br/>
<tr>
<td><%= $book->name %></td>
<td><%= $book->author->name %>
</td></tr>
% }
</table>
</div>
<p/>