0
votes

How to change cakephp concept user belongsTo Group, to user hasMany Group, apart make new table called users_groups, and what should I change to make my user really have access to many groups that user have?

2

2 Answers

0
votes

Make Things Simple:

In such scenario you already needed three tables.

Users table

  • id
  • name
  • phone

Groups

  • id
  • group(title)

User_Groups

  • id
  • user_id
  • group_id

As you need relations like user has many groups then you need extra table which at least should include foreign key like user_id, and group_id.So don't hesitate to add extra table for making things simple.

0
votes

You'd be using 3 tables, and then a HasAndBelongsToMany relationship over the Users_Groups. Users HABTM Groups