| 1 | package Mojolicious::Plugin::RoutesAuthDBI::Model::Controllers; | ||
| 2 | #~ use Mojo::Base 'DBIx::Mojo::Model'; | ||
| 3 | use Mojo::Base 'Mojolicious::Plugin::RoutesAuthDBI::Model::Base'; | ||
| 4 | |||
| 5 | #~ sub new { | ||
| 6 | #~ state $self = shift->SUPER::new(@_); | ||
| 7 | #~ } | ||
| 8 | |||
| 9 | sub controller_ns { | ||
| 10 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 11 | |||
| 12 | $self->dbh->selectrow_hashref($self->sth('controller', where => "where controller=? and (namespace=? or (?::varchar is null and namespace is null))"), undef, @_); | ||
| 13 | } | ||
| 14 | |||
| 15 | sub controller_id_ns { | ||
| 16 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 17 | |||
| 18 | $self->dbh->selectrow_hashref($self->sth('controller', where=>"where (id=? or controller=?) and (namespace_id = ? or namespace = ? or (?::varchar is null and namespace is null))"), undef, (@_)); | ||
| 19 | } | ||
| 20 | |||
| 21 | sub new_controller { | ||
| 22 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 23 | |||
| 24 | $self->dbh->selectrow_hashref($self->sth('new controller'), undef, (@_)); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub controllers { | ||
| 28 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 29 | |||
| 30 | $self->dbh->selectall_arrayref($self->sth('controllers'), { Slice => {} }, ); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub controllers_ns_id { | ||
| 34 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 35 | |||
| 36 | $self->dbh->selectall_arrayref($self->sth('controllers', where=>"where n.id=? or (?::int is null and n.id is null)"), { Slice => {} }, (@_)); | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __DATA__ |