View Single Post
  #2  
Old 08-11-2019, 03:50 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: How to show all products related to an entity in another model

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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote