/var/www/vhosts/ihelp.ro/_OLD/src/Model/Table
Edit: /var/www/vhosts/ihelp.ro/_OLD/src/Model/Table/CausesTable.php (3282B)
setTable('causes');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER',
]);
$this->hasMany('CauseImages', [
'foreignKey' => 'cause_id',
]);
}
/*
*
*/
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
$entity->uuid = uniqid();
$entity->slug = preg_replace('/\s+/', '-', $entity->name);
}
/**
* Default validation rules.
*/
// public function validationDefault(Validator $validator): Validator
// {
// $validator
// ->integer('id')
// ->allowEmptyString('id', null, 'create');
// $validator
// ->scalar('uuid')
// ->maxLength('uuid', 100)
// ->requirePresence('uuid', 'create')
// ->notEmptyString('uuid');
// $validator
// ->scalar('name')
// ->maxLength('name', 255)
// ->requirePresence('name', 'create')
// ->notEmptyString('name');
// $validator
// ->scalar('slug')
// ->maxLength('slug', 255)
// ->requirePresence('slug', 'create')
// ->notEmptyString('slug');
// $validator
// ->scalar('description')
// ->maxLength('description', 255)
// ->requirePresence('description', 'create')
// ->notEmptyString('description');
// $validator
// ->scalar('donation_amount')
// ->maxLength('donation_amount', 255)
// ->requirePresence('donation_amount', 'create')
// ->notEmptyString('donation_amount');
// $validator
// ->dateTime('date_start')
// ->requirePresence('date_start', 'create')
// ->notEmptyDateTime('date_start');
// $validator
// ->dateTime('date_end')
// ->requirePresence('date_end', 'create')
// ->notEmptyDateTime('date_end');
// $validator
// ->boolean('is_active')
// ->requirePresence('is_active', 'create')
// ->notEmptyString('is_active');
// return $validator;
// }
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*/
// public function buildRules(RulesChecker $rules): RulesChecker
// {
// $rules->add($rules->existsIn(['user_id'], 'Users'), ['errorField' => 'user_id']);
// $rules->add($rules->existsIn(['cause_image_id'], 'CauseImages'), ['errorField' => 'cause_image_id']);
// return $rules;
// }
}