What I need:
A facebook-like friendship system.
User (A)
sends a requests for a friendship withUser (B)
User (B)
confirmes the requestUser (A)
andUser (B)
are friends now
My problem:
I'm confused how to work this out. I read a lot on the internet but it did not really helped me...
My Questions:
- What kind of link is it in CakePHP? Is it hasAndBelongsToMany? Or hasMany? Or ...?
- How do I realise it in the datebase correctly?
- How do I link it in the model?
What I already did:
Table: users
Name: id
, username
, password
, ...
users_users table: id
, user_id
, friend_id
, approved
Model:
'User' => array(
'className' => 'User',
'joinTable' => 'users_users',
'foreignKey' => 'user_id',
'associationForeignKey' => 'friend_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
);