Reputation: 297
How would I enforce a model constraint for a table users, where not only does the username have to be unique for the users table, but also cannot exist in another table? Thanks!
Upvotes: 0
Views: 208
Reputation: 521995
public $validate = array(
'username' => array(
'unique' => array(
'rule' => 'veryUnique',
...
)
)
);
public function veryUnique($data) {
return $this->isUnique($data) && $this->OtherModel->isUnique($data);
}
Upvotes: 2