Good afternoon,
I`m new using cakephp and I got some questions that I couldn`t figure how 
to solve.
Let me introduce an example:

i have the following tables
USERS hasmany MASTERS
MASTERS hasmany CLIENTS and belongs to USERS
CLIENTS has many GROUPS and belongs to MASTERS

Now in the add page of GROUPSI have a dropdown that I can select MASTERS 
records and CLIENTSrecords.
With this how can I filter the dropdown to show just the TABLE1 that are 
from the logged user?

I tried like this to the index, it works but I think that must be a more 
intelligent form of doing it

$this->User->unbindModel(array('belongsTo'=>array('Client')));

$options = array(
'joins' => array(
  array(
'table' => 'clients',
'alias' => 'Client',
'type'  => 'LEFT',
'conditions' => array(
  'client.id = group.client_id'
)
  ),
  array(
'table' => 'masters',
'alias' => 'master',
'type'  => 'LEFT',
'conditions' => array(
  'master.id = client.master_id'
)
  )
),
'fields' => array(
  'group.id',
  'group.nome',
  'Client.id',
  'Client.cliente',
),
'conditions' => array(
  'master.user_id' => $this->Session->read('Auth.User.id')
)
  
);
 $groups = $this->Group->find('all', $options); 
$this->set(compact('groups'));

Or simply should I put user_id in all tables???

Thanks for the support guys
Augusto

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to