For true I'm receiving "Successfully UNENLISTED(1)!" and for false I'm receiving "Successfully ENLISTED(1)!".
dump($swap) will return true and still execute the IF else while if it returns false it still execute as true
Am i not understanding something specific to CakePHP?
//to grab database entry
public function swapSub($user_id_main, $user_id_from) {
$result = $this->find()
->where(['Enlist.user_id_main'=>$user_id_main,'Enlist.user_id_for'=>$user_id_from])
->first();
dump($result);
if($result['active']){
$result['active'] = 0;
if($this->save($result)){
return false;
}
} else {
$result['active'] = 1;
if($this->save($result)){
return true;
}
}
}
//display true and false statement. //$swap == TRUE/does not work either
$swap = $this->Enlist->swapSub($user_id_main, $user_id_from);
dump($swap);
if($swap){
$this->Flash->success(__('Successfully ENLISTED(1)!'));
} else {
$this->Flash->success(__('Successfully UNENLISTED(1)!'));
}