cerebrate/src/Model/Table/UsersTable.php

45 lines
992 B
PHP
Raw Normal View History

2020-06-19 00:42:10 +02:00
<?php
namespace App\Model\Table;
use App\Model\Table\AppTable;
use Cake\ORM\Table;
use Cake\Validation\Validator;
2020-06-21 21:27:11 +02:00
use Cake\ORM\RulesChecker;
2020-06-19 00:42:10 +02:00
class UsersTable extends AppTable
{
public function initialize(array $config): void
{
parent::initialize($config);
$this->addBehavior('UUID');
$this->belongsTo(
'Individuals',
[
'dependent' => false,
'cascadeCallbacks' => false
]
);
$this->belongsTo(
'Roles',
[
'dependent' => false,
'cascadeCallbacks' => false
]
);
2020-06-21 21:27:11 +02:00
$this->setDisplayField('username');
2020-06-19 00:42:10 +02:00
}
public function validationDefault(Validator $validator): Validator
{
$validator
->requirePresence(['password'], 'create');
return $validator;
}
2020-06-21 21:27:11 +02:00
public function buildRules(RulesChecker $rules): RulesChecker
{
return $rules;
}
2020-06-19 00:42:10 +02:00
}