/var/www/vhosts/ihelp.ro/_OLD/src/Model/Table
Edit: /var/www/vhosts/ihelp.ro/_OLD/src/Model/Table/ProfilesTable.php (3851B)
setTable('profiles');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->integer('id')
->allowEmptyString('id', null, 'create');
$validator
->scalar('first_name')
->maxLength('first_name', 255)
->requirePresence('first_name', 'create')
->notEmptyString('first_name');
$validator
->scalar('last_name')
->maxLength('last_name', 255)
->requirePresence('last_name', 'create')
->notEmptyString('last_name');
$validator
->scalar('address')
->maxLength('address', 255)
->requirePresence('address', 'create')
->notEmptyString('address');
$validator
->integer('phone')
->requirePresence('phone', 'create')
->notEmptyString('phone');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn(['user_id'], 'Users'), ['errorField' => 'user_id']);
return $rules;
}
}