Trends adlı üyeden alıntı: mesajı görüntüle
Merhaba arkadaşlar,

Aşağıdaki gibi bir kod satırım var.

            $data = [
                'title' => $this->request->getVar('title'),
                'cid' => $this->request->getVar('cid'),
                'openingSpeech' => $this->request->getVar('openingSpeech'),
                'isPublic' => $this->request->getVar('isPublic'),
                'uid' => '1',
                'reminder' => $this->request->getVar('reminder'),
                'createdAt' =>  date('Y-m-d H:i:s')
            ];
Form'dan gelen veri isPublic için On yada boş, on durumunda 1, boş durumunda ise 0 yapmak istiyorum. Yardımcı olur musunuz?

if($this->request->getVar('isPublic') == "on"){
  $isPublic = 1;
}else{
  $isPublic = 0;
}
$data = [
    'title' => $this->request->getVar('title'),
    'cid' => $this->request->getVar('cid'),
    'openingSpeech' => $this->request->getVar('openingSpeech'),
    'isPublic' => $isPublic, 
    'uid' => '1',
    'reminder' => $this->request->getVar('reminder'),
    'createdAt' =>  date('Y-m-d H:i:s')
];