pgc-www/lib/MyModel/Book.pm
barnold 8dcdb9fb10 Improve the book listing...
Add order_by.  Prefetch author and show author's name.  Add table
markup.
2022-09-17 16:28:17 +01:00

26 lines
552 B
Perl

package MyModel::Book;
use feature qw( signatures );
use Moose;
extends 'MyModel';
no warnings qw( experimental::signatures );
sub count_all ($self) {
my $book_count = $self->schema->resultset('Book')->count;
return $book_count;
}
sub get_page ($self, $page_number = 1) {
my $rs = $self->schema->resultset('Book')->search_rs(
undef,
{ prefetch => [ "author" ],
order_by => [ "me.name " ],
page => $page_number,
rows => 10,
},
);
return $rs;
}
no Moose;
__PACKAGE__->meta->make_immutable;