Skip to content

Instantly share code, notes, and snippets.

@SebDeclercq
Created June 5, 2012 15:22
Show Gist options
  • Save SebDeclercq/2875643 to your computer and use it in GitHub Desktop.
Save SebDeclercq/2875643 to your computer and use it in GitHub Desktop.
Code moche mais fonctionnel
any [ 'get', 'post' ] => '/law/:numid' => sub {
my $numid = params->{numid};
my ($lawid);
my $rs = schema->resultset('Law')->search();
while (my $law = $rs->next) {
my @lawvs = $law->law_versions;
for (@lawvs) {
if ($_->numid() eq $numid ) {
my @lawids = $_->lawid();
$lawid = $_->id for $lawids[0];
}
}
}
my @laws = schema->resultset('Law')->search ( { id => $lawid } );
my @lawvs = schema->resultset('LawVersion')->search ( { numid => $numid } );
my @preambles = schema->resultset('Preamble')->search ( { numid => $numid } );
my @articles = schema->resultset('Article')->search ( { numid => $numid }, { order_by => { -asc => 'numord' } } );
my @appendixes = schema->resultset('Appendix')->search ( { numid => $numid}, { order_by => { -asc => 'numart' } } );
template 'law',{laws => \@laws,
lawvs => \@lawvs,
preambles => \@preambles,
articles => \@articles,
appendixes => \@appendixes,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment