/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table/CauseNewsTable.php (1877B)
setTable('cause_news');
$this->setDisplayField('title');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Causes', [
'foreignKey' => 'cause_id',
'joinType' => 'INNER',
]);
}
/**
* Default validation rules.
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->integer('id')
->allowEmptyString('id', null, 'create');
$validator
->integer('cause_id')
->requirePresence('cause_id', 'create')
->notEmptyString('cause_id');
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->scalar('content')
->requirePresence('content', 'create')
->notEmptyString('content');
$validator
->boolean('is_published')
->notEmptyString('is_published');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn(['cause_id'], 'Causes'), ['errorField' => 'cause_id']);
return $rules;
}
}