Tuesday, September 16, 2008

Ideas about models and associations

Hi!

I'm working on a new project and right now I'm struggling a bit to put
the requirements together in a proper cake-like way.

I use Auth/ACL which is set up and works fine. The users who can log-in
belong to three different groups. These groups are defined by a field
"role_id" in the user table.

Now I want to add profiles for the users. The problem is that each group
has a different type of profile with different fields in it so I defined
three models for the profiles.

My first idea was to do something like this in my user model:

var $hasOne = array(
'AdminProfile' => array(
'className' => 'AdminProfile',
'conditions' => 'User.role_id = 1'
),
'EditorProfile' => array(
'className' => 'EditorProfile',
'conditions' => 'User.role_id = 2'
),
'ReviewerProfile' => array(
'className' => 'ReviewerProfile',
'conditions' => 'User.role_id = 3'
)
);

Which seems to work to a degree but is a bit of a hassle when it comes
to editing the profiles and validating the form data.

How would you solve this?

Regards
Guenther

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: