From 1fde2d7a8efe0b2ac269793fdfbedfbc2ec90925 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 19 Jun 2020 00:39:29 +0200 Subject: [PATCH] fix: [Individuals Model] Table updated with relations and smarter UUID handling --- app/src/Model/Table/IndividualsTable.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/Model/Table/IndividualsTable.php b/app/src/Model/Table/IndividualsTable.php index 941ea84..2e56e19 100644 --- a/app/src/Model/Table/IndividualsTable.php +++ b/app/src/Model/Table/IndividualsTable.php @@ -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; } }