40 lines
938 B
PHP
40 lines
938 B
PHP
<?php
|
|
|
|
namespace App\Model\Table;
|
|
|
|
use App\Model\Table\AppTable;
|
|
use Cake\ORM\Table;
|
|
use Cake\Validation\Validator;
|
|
|
|
class OrganisationsTable extends AppTable
|
|
{
|
|
public function initialize(array $config): void
|
|
{
|
|
parent::initialize($config);
|
|
$this->hasMany(
|
|
'Alignments',
|
|
[
|
|
'dependent' => true,
|
|
'cascadeCallbacks' => true
|
|
]
|
|
);
|
|
$this->hasMany(
|
|
'EncryptionKeys',
|
|
[
|
|
'foreignKey' => 'owner_id',
|
|
'conditions' => ['owner_type' => 'organisation']
|
|
]
|
|
);
|
|
$this->setDisplayField('name');
|
|
}
|
|
|
|
public function validationDefault(Validator $validator): Validator
|
|
{
|
|
$validator
|
|
->notEmptyString('name')
|
|
->notEmptyString('uuid')
|
|
->requirePresence(['name', 'uuid'], 'create');
|
|
return $validator;
|
|
}
|
|
}
|