/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table/DonationsTable.php (2965B)
setTable('donations');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
]);
$this->belongsTo('Causes', [
'foreignKey' => 'cause_id',
]);
$this->belongsTo('Orders', [
'foreignKey' => 'order_id',
]);
$this->belongsTo('Transactions', [
'foreignKey' => 'transaction_id',
]);
$this->hasMany('PaymentLogs', [
'foreignKey' => 'donation_id',
]);
}
/**
* Default validation rules.
*/
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('nickname')
->maxLength('nickname', 255)
->allowEmptyString('nickname');
$validator
->email('email')
->notEmptyString('email');
$validator
->scalar('message')
->allowEmptyString('message');
$validator
->decimal('value')
->requirePresence('value', 'create')
->notEmptyString('value');
$validator
->decimal('ihelp_value')
->notEmptyString('ihelp_value');
$validator
->boolean('is_anonymous')
->notEmptyString('is_anonymous');
$validator
->boolean('is_visible')
->notEmptyString('is_visible');
$validator
->boolean('is_active')
->notEmptyString('is_active');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn(['user_id'], 'Users'), ['errorField' => 'user_id']);
$rules->add($rules->existsIn(['cause_id'], 'Causes'), ['errorField' => 'cause_id']);
$rules->add($rules->existsIn(['order_id'], 'Orders'), ['errorField' => 'order_id']);
return $rules;
}
}