fix: [Individuals Model] Table updated with relations and smarter UUID handling

remotes/origin/main
iglocska 2020-06-19 00:39:29 +02:00
parent e7cc383cbf
commit 1fde2d7a8e
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 8 additions and 2 deletions

View File

@ -11,6 +11,7 @@ class IndividualsTable extends AppTable
public function initialize(array $config): void
{
parent::initialize($config);
$this->addBehavior('UUID');
$this->hasMany(
'Alignments',
[
@ -25,6 +26,12 @@ class IndividualsTable extends AppTable
'conditions' => ['owner_type' => 'individual']
]
);
$this->hasOne(
'Users'
);
$this->belongsToMany('Organisations', [
'through' => 'Alignments',
]);
$this->setDisplayField('email');
}
@ -32,8 +39,7 @@ class IndividualsTable extends AppTable
{
$validator
->notEmptyString('email')
->notEmptyString('uuid')
->requirePresence(['email', 'uuid'], 'create');
->requirePresence(['email'], 'create');
return $validator;
}
}