aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Body.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-12-14 19:07:08 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-12-19 14:43:26 +0000
commitddf9dbdbf6486c781ca4a5822614b0b7cee2c062 (patch)
tree09c12affc3390138b03292d3f90810287b4941d0 /perllib/FixMyStreet/DB/ResultSet/Body.pm
parentda29e8a75eaa92e98807ad89d29d3d1f3c01bc14 (diff)
Allow bodies to span multiple area IDs, and areas can be covered by more than one body.
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Body.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Body.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Body.pm b/perllib/FixMyStreet/DB/ResultSet/Body.pm
new file mode 100644
index 000000000..6802ed604
--- /dev/null
+++ b/perllib/FixMyStreet/DB/ResultSet/Body.pm
@@ -0,0 +1,17 @@
+package FixMyStreet::DB::ResultSet::Body;
+use base 'DBIx::Class::ResultSet';
+
+use strict;
+use warnings;
+
+sub for_areas {
+ my ( $rs, @areas ) = @_;
+
+ my $result = $rs->search(
+ { 'body_areas.area_id' => \@areas },
+ { join => 'body_areas' }
+ );
+ return $result;
+}
+
+1;