46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Model\Table;
|
|
|
|
use App\Model\Table\AppTable;
|
|
use Cake\ORM\Table;
|
|
use Cake\Validation\Validator;
|
|
|
|
class IndividualsTable extends AppTable
|
|
{
|
|
public function initialize(array $config): void
|
|
{
|
|
parent::initialize($config);
|
|
$this->addBehavior('UUID');
|
|
$this->hasMany(
|
|
'Alignments',
|
|
[
|
|
'dependent' => true,
|
|
'cascadeCallbacks' => true
|
|
]
|
|
);
|
|
$this->hasMany(
|
|
'EncryptionKeys',
|
|
[
|
|
'foreignKey' => 'owner_id',
|
|
'conditions' => ['owner_type' => 'individual']
|
|
]
|
|
);
|
|
$this->hasOne(
|
|
'Users'
|
|
);
|
|
$this->belongsToMany('Organisations', [
|
|
'through' => 'Alignments',
|
|
]);
|
|
$this->setDisplayField('email');
|
|
}
|
|
|
|
public function validationDefault(Validator $validator): Validator
|
|
{
|
|
$validator
|
|
->notEmptyString('email')
|
|
->requirePresence(['email'], 'create');
|
|
return $validator;
|
|
}
|
|
}
|