When I get Successfully UNENLISTED(1)! the database saves the digit as 1 and when i get the response Successfully ENLISTED(1)! database saves the digit as 0. I'm very lost and confused from my problem. Is there something special I'm not understanding with CakePHP?
public function enlist($user_id_main, $user_id_from) {
$this->render(false);
$this->loadModel('Enlist');
$enlist = $this->Enlist->getEnlist($user_id_main, $user_id_from);
if (!empty($enlist)){
dump($enlist);
dump($this->Enlist->isActiveSub($user_id_main, $user_id_from));
if ($enlist['active']) {
$enlist -> active = 0;
if($this->Enlist->save($enlist)) {
dump($enlist);
$this->Flash->success(__('Successfully UNENLISTED(1)!'));
}
} else {
$enlist -> active = 1;
if($this->Enlist->save($enlist)) {
dump($enlist);
$this->Flash->success(__('Successfully ENLISTED(1)!'));
}
}
} else {
$en = $this->Enlist->newEntity(['validate'=>'validationForEnlist']);
$en['user_id_main'] = $user_id_main;
$en['user_id_for'] = $user_id_from;
$en['permited'] = 1;
$en['active'] = 1;
if ($this->Enlist->save($en)){
$this->Flash->success(__('Successfully ENLISTED!'));
}
}
}