This method would go into your Team model, assuming all assocs and HABTM are set up right.
public function createTeam($postData) {
$this->set($postData);
$this->User->set($postData);
$validTeam = $this->validates();
$validUser = $this->User->validates()
if ($validTeam && $validUser) {
$this->create();
$this->save($postData, array('validate' => false);
$this->User->create();
$this->User->save($postData, array('validate' => false);
$this->TeamsUser->create();
$this->TeamsUser->save(array(
'TeamsUser' => array(
'user_id' => $this->getLastInsertId()
'team_id' => $this->User->getLastInsertId()
)
));
return true;
}
return false;
}