This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Foodloop-Server/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm

60 lines
1.2 KiB
Perl
Raw Normal View History

package Pear::LocalLoop::Controller::Admin::Feedback;
use Mojo::Base 'Mojolicious::Controller';
has result_set => sub {
2021-03-20 12:09:50 +00:00
my $c = shift;
return $c->schema->resultset('Feedback');
};
2021-03-20 19:03:59 +00:00
sub idx {
2021-03-20 12:09:50 +00:00
my $c = shift;
my $feedback_rs = $c->result_set->search(
undef,
{
page => $c->param('page') || 1,
rows => 12,
order_by => { -desc => 'submitted_at' },
},
);
$c->stash( feedback_rs => $feedback_rs );
2021-03-20 15:02:00 +00:00
return 1;
}
2021-03-20 19:03:59 +00:00
sub get {
2021-03-20 12:09:50 +00:00
my $c = shift;
2021-03-20 12:09:50 +00:00
my $id = $c->param('id');
2021-03-20 12:09:50 +00:00
if ( my $feedback = $c->result_set->find($id) ) {
$c->stash( feedback => $feedback );
}
else {
$c->flash( error => 'No Feedback found' );
$c->redirect_to('/admin/feedback');
}
2021-03-20 15:02:00 +00:00
return 1;
}
sub actioned {
2021-03-20 12:09:50 +00:00
my $c = shift;
my $id = $c->param('id');
if ( my $feedback = $c->result_set->find($id) ) {
$feedback->actioned( !$feedback->actioned );
$feedback->update;
$c->redirect_to( '/admin/feedback/' . $id );
}
else {
$c->flash( error => 'No Feedback found' );
$c->redirect_to('/admin/feedback');
}
2021-03-20 15:02:00 +00:00
return 1;
}
1;