|
sub index {
my $c = shift ;
my $sort = $c ->param( 'order' ) || 'desc' ;
my $order = ( $sort eq 'desc' ) ? 'asc' : ( $sort eq 'asc' ) ? 'desc' : 'desc' ;
my ( $table ) = $c ->qselect( 'models' ,
{},
{
order_by => { $sort => 'id' },
limit => 10,
}
);
$c ->stash(
table => $table ,
count => $c ->qcount( 'models' ),
order => $order ,
);
$c ->render;
}
sub edit {
my $c = shift ;
my $id = $c ->param( 'id' );
$c ->qupdate( 'models' , { id => $id }, { name => 'New York' ,
} );
$c ->redirect_to( '/' );
}
sub insert {
my $c = shift ;
$c ->app-> log ->info( $id );
$c ->redirect_to( '/' );
}
sub delete {
my $c = shift ;
my $id = $c ->param( 'id' );
$c ->qdelete( 'models' , { id => $id });
$c ->redirect_to( '/' );
}
1;
|