Hi all,
I am just develloping an app where a table ‘offices’ exsists.
I have baked the controller, Model and Views. Now it turns out, I can store new data but the data is not retreived from mysql. There is no error displayed and the app is not interrupted. No info for identifying the error.
I have installed the latest cakephp version.
Any idea where I can start making more research?
This is the code on OfficesTable.php:
class OfficesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->table('offices');
$this->displayField('id');
$this->primaryKey('id');
$this->belongsTo('Cities', [
'foreignKey' => 'city_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Persons', [
'foreignKey' => 'person_id',
'joinType' => 'INNER'
]);
$this->hasMany('Events', [
'foreignKey' => 'office_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->integer('id')
->allowEmpty('id', 'create');
$validator
->requirePresence('office', 'create')
->notEmpty('office');
$validator
->requirePresence('street', 'create')
->notEmpty('street');
$validator
->requirePresence('no', 'create')
->notEmpty('no');
$validator
->requirePresence('phone', 'create')
->notEmpty('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)
{
$rules->add($rules->isUnique(['email']));
$rules->add($rules->existsIn(['city_id'], 'Cities'));
$rules->add($rules->existsIn(['person_id'], 'Persons'));
return $rules;
}
}