Permalink
Browse files

Updated DBIx::Class Result Class Files for many-to-many relations

  • Loading branch information...
1 parent 5e316ee commit f811188dcae9dbed6e294f6a3ef2ecc742092512 @phillipadsmith committed Aug 15, 2011
Showing with 18 additions and 0 deletions.
  1. +9 −0 lib/Catalyst/Default/Schema/Result/Author.pm
  2. +9 −0 lib/Catalyst/Default/Schema/Result/Book.pm
@@ -80,5 +80,14 @@ __PACKAGE__->has_many(
# You can replace this text with custom code or comments, and it will be preserved on regeneration
+
+ # many_to_many():
+ # args:
+ # 1) Name of relationship bridge, DBIC will create accessor with this name
+ # 2) Name of has_many() relationship this many_to_many() is shortcut for
+ # 3) Name of belongs_to() relationship in model class of has_many() above
+ # You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(books => 'book_authors', 'book');
+
__PACKAGE__->meta->make_immutable;
1;
@@ -80,5 +80,14 @@ __PACKAGE__->has_many(
# You can replace this text with custom code or comments, and it will be preserved on regeneration
+
+# many_to_many():
+ # args:
+ # 1) Name of relationship bridge, DBIC will create accessor with this name
+ # 2) Name of has_many() relationship this many_to_many() is shortcut for
+ # 3) Name of belongs_to() relationship in model class of has_many() above
+ # You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(authors => 'book_authors', 'author');
+
__PACKAGE__->meta->make_immutable;
1;

0 comments on commit f811188

Please sign in to comment.