table('admin_mappings'); $this->displayField('id'); $this->primaryKey('id'); $this->addBehavior('Timestamp'); $this->belongsTo('Users', [ 'foreignKey' => 'user_id', 'joinType' => 'INNER' ]); $this->belongsTo('AccountMappings', [ 'foreignKey' => 'account_mapping_id', 'joinType' => 'INNER' ]); } /** * Default validation rules. * * @param \Cake\Validation\Validator $validator Validator instance. * @return \Cake\Validation\Validator */ public function validationDefault(Validator $validator) { $validator ->uuid('id') ->allowEmpty('id', 'create'); 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) { $rules->add($rules->existsIn(['user_id'], 'Users')); $rules->add($rules->existsIn(['account_mapping_id'], 'AccountMappings')); $rules->add($rules->isUnique(['account_mapping_id', 'user_id']), ['message' => 'unique error']); return $rules; } }