I have the following code in edit method that allows a user to edit their account details. It uses both the User and Profile models and should be updating both.
I have used the contain in the find to load in the Profile information and also called the Profile model using the $uses var at the top of the controller.
But how do I load in both models into the read method?
$user = $this->User->find('first', array(
'conditions' => array('User.id' => $this->Auth->user('id')),
'contain'=>'Profile'
));
if ($this->request->is('post') || $this->request->is('put'))
{
if ($this->User->save($this->request->data))
{
$this->Session->setFlash(__('Your account has been saved'));
$this->redirect(array('controller'=>'users','action'=>'edit'));
}
else
{
$this->Session->setFlash(__('Whoops! Something went wrong... try again?'));
}
}
else
{
$this->request->data = $this->User->read(null, $user['User']['id']);
}