In your model for activity you would need to define the foreign key.
In this example user_id(customer) = "customer_id" and user_id(Customer
Service Agenet) = "csa_id":
var $belongsTo = array(
'Customer' => array (
'classname' => 'User',
'foreignKey' => 'customer_id'
),
'CSA' => array (
'classname' => 'User',
'foreignKey' => 'csa_id'
));
On Nov 20, 2:39 pm, Mohammad Raheel <[email protected]> wrote:
> Hi guys,
>
> I need to know how do i keep two user_id fields in a single table in
> CakePHP. For example:
>
> I have a "users" table. There are two type of users in this table. 1.
> Customers, 2. Customer Service Agents.
> I have another table "activity" which shall hold all activities
> performed on a customer and who (Customer Service Agent) performed
> that activity.
>
> users
> --------
>
> id, username, role
> 1, john, Customer
> 2, mate Customer Service Agent
>
> activity
> ----------
>
> id, created, title, user_id
> (customer) user_id (Customer Service Agent)
>
> 1 xxx Agent called the customer
> John Mate
> 2 xxxx Agent changed customer's info
> John Mate
>
> Really need help with best practice how to do this in cake as i'm
> stuck here.
>
> Appreciate any help.
--
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=.