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/Users.pm
2017-04-18 19:03:03 +01:00

36 lines
669 B
Perl

package Pear::LocalLoop::Controller::Admin::Users;
use Mojo::Base 'Mojolicious::Controller';
has result_set => sub {
my $c = shift;
return $c->schema->resultset('User');
};
sub index {
my $c = shift;
my $user_rs = $c->result_set;
$user_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
$c->stash( users => [ $user_rs->all ] );
}
sub read {
my $c = shift;
my $id = $c->param('id');
if ( my $user = $c->result_set->find($id) ) {
$c->stash( user => $user );
} else {
$c->flash( error => 'No User found' );
$c->redirect_to( '/admin/users' );
}
}
sub update {
my $c = shift;
$c->redirect_to( '/admin/users' );
}
1;