Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

cakephp association confusion

Hi,

I have a simple question on associations in cakephp.
I have a user , role and tutor table.
The  issue is how do i define this where I have a admin user who can view tutors but there is no tutor entry with this user? Or do I need to bother  as not all users are tutors anyway.

I can create a user that is a tutor and have the userID in the tutor table as a foreign key.
The role is the user type like admin, tutor etc which is linked to the user.



 public $belongsTo = array(
        'User' => array(
            'className' => 'User',
            'foreignKey' => 'user_id'
        )
    );

 public $hasOne = array(
        'Tutor' => array(
            'className' => 'Tutor',
            'dependent' => true
        )......



http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
ASKER CERTIFIED SOLUTION
Avatar of Scott Madeira
Scott Madeira
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial