Quote:
Originally Posted by Ed B.
... I made a model for entities "Author" in ManyToMany relationship with the model Product.
|
First of all why are you making Many To Many relationship? If you do this it means one book can be written by more than one author. I mean there are cases when a book has multiple co-writers but they are usually treated as team?
I would change that to One Book One Writer and One Writer Many Books relationship.
The you can easily get Author/Books by using Book->getAuthor() and Author->getBooks()
Even with Many To Many connection you still use Entity->getBooks() and Entity->getAuthors()
There is no need of any fancy functions.