I'm writing a cake app where I'm trying to model a situation where a group has permissions to services, and users in that group can have a subset of those permissions. If the group loses permission to a service, the users in that group should also lose permission.
My tables:
groups (id), services (id), groups_services (id, service_id, group_id), users (id, group_id), users_services (id, groups_services_id, user_id)
Currently, groups has a HABTM relationship with services. The problem is that if I remove a group from a service, then it should be removed from all users in that group as well. I know normally with CakePHP you can do this by having a dependent => true defined on your model relationship, but in this case, users_services is dependent on the join table, groups_services, that represents the HABTM, so I don't think this will work. Will I have to break up the HABTM relationship in order to get this to work, and use instead groups hasMany groups_services and services hasMany group_services?