Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit f811188dcae9dbed6e294f6a3ef2ecc742092512 1 parent 5e316ee
@phillipadsmith authored
View
9 lib/Catalyst/Default/Schema/Result/Author.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;
View
9 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(authors => 'book_authors', 'author');
+
__PACKAGE__->meta->make_immutable;
1;
Please sign in to comment.
Something went wrong with that request. Please try again.