Code for viewing single transaction added
This commit is contained in:
parent
e330812cf8
commit
e7631dd90e
5 changed files with 127 additions and 0 deletions
49
lib/Pear/LocalLoop/Controller/Admin/Transactions.pm
Normal file
49
lib/Pear/LocalLoop/Controller/Admin/Transactions.pm
Normal file
|
@ -0,0 +1,49 @@
|
|||
package Pear::LocalLoop::Controller::Admin::Transactions;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
has result_set => sub {
|
||||
my $c = shift;
|
||||
return $c->schema->resultset('Transaction');
|
||||
};
|
||||
|
||||
sub index {
|
||||
my $c = shift;
|
||||
|
||||
my $transactions = $c->result_set->search(
|
||||
undef, {
|
||||
page => $c->param('page') || 1,
|
||||
rows => 10,
|
||||
order_by => { -desc => 'submitted_at' },
|
||||
},
|
||||
);
|
||||
$c->stash(
|
||||
transactions => $transactions,
|
||||
);
|
||||
}
|
||||
|
||||
sub read {
|
||||
my $c = shift;
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
if ( my $transaction = $c->result_set->find($id) ) {
|
||||
$c->stash( transaction => $transaction );
|
||||
} else {
|
||||
$c->flash( error => 'No transaction found' );
|
||||
$c->redirect_to( '/admin/transactions' );
|
||||
}
|
||||
}
|
||||
|
||||
sub image {
|
||||
my $c = shift;
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
my $transaction = $c->result_set->find($id);
|
||||
|
||||
if ( $transaction->proof_image ) {
|
||||
$c->reply->asset($c->get_file_from_uuid($transaction->proof_image));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
Reference in a new issue