简体   繁体   中英

Cakephp - Multiple users with different profile fields

I have three different type of users with different columns for profiles.

I currently have Users table and Groups table with Users table linking to Groups.

How can I set it so that it picks up different type of profiles for each group users?

you can use $belongsTo relation for linking for both table, such that every user belongs to some group.

For that you need to create model of user. Try something like following code

class Users extends AppModel {

    var $name = 'Users';
    public $belongsTo = array(
        'Groups' => array(
            'className' => 'Groups',
            'foreignKey' => 'group_id'
        )
    );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM