I am stumped on setting up model relationship for my site.
I am building an education site with 4 user groups. The 2 in question are
STUDENTS and TEACHERS. How I have set it up there are 2 registration forms
to create the USER (TEACHERS or STUDENTS) so on sign up it creates the USER
and TEACHER_PROFILE or USER and STUDENT_PROFILE (I set it up this way
because the profiles have completely different information)
TEACHERS can add a posts / article
STUDENTS can read the posts / articles
but I want to have it so a STUDENT can bookmark a TEACHERS article. So what
table do I need to create and the fields I would need? I know the STUDENT
TABLE needs a join table but cant quite figure out the way to set it up. Do
I need a students_posts table with:
ID, student_id, post_id then link it up in the STUDENT MODEL?
TEACHER MODEL:
$belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Group' => array('className' => 'Group',
'foreignKey' => 'group_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
var $hasMany = array(
'Post' => array('className' => 'Post',
'foreignKey' => 'teacher_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
STUDENT MODEL:
$belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Group' => array('className' => 'Group',
'foreignKey' => 'group_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---