I think there are no hard and fast rules for this. I've done that in the past where it seems to make sense to list the associated model data from a particular controller. If all you want to do is list the Members of a given Organization -- and not provide links to do anything further with a given Member -- then it might be fine to put the action in OrganizationsController. However, I'll generally create a controller for the other model(s), if only for admin functions. In your case, you may have a need for an admin to create a new OrganizationRole, for example.
On Sun, Apr 22, 2012 at 12:45 PM, bs28723 <[email protected]> wrote: > My question is - Is it a better MVC architecture to have a 1 to 1 > relationship for a controller to access the model and the view, or since > in a case where all relationships stem from a single model - just make > the one controller have all the actions, but pull data from the related > models needed together to then send to a view. > > Here is some code to help illustrate what I am talking about. ( I > removed a lot of configuration details, because it is not relevant for > the architecture discussion) > > Organization Model > $hasMany = array('OrganizationRole', 'Address', 'MemberRelationship'); > $belongsTo = array('User'); > > OrganizationRole Model > $hasMany = array('OrganizationPermission', 'MemberRelationship'); > $belongsTo = array('Organization'); > > MemberRelationship Model > $belongsTo = array('Organization', 'User', 'MembershipLevel', > 'OrganizationRole'); > > OrganizationPermission Model > $belongsTo = array('OrganizationRole'); > > User Model > $hasMany = array('Organization', 'MemberRelationship', 'Address'); > > > So, as you can see, everything is related to Organization either > directly or indirectly. So, I am thinking of adding actions to > OrganizationsController to do things like viewMembers, editMembers, > deleteMembers, viewRoles, editRoles, assignRoles, etc > rather than putting calling view, edit, delete actions in > MemberRelationshipsController and OrganizationRolesControllers. > > Any thoughts? Opinions? Suggestions? > > Thanks, > Bill > > ________________________________ > View this message in context: Understanding MVC Architecture > Sent from the CakePHP mailing list archive at Nabble.com. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
