1
私は通知があるかどうかをチェックしたいが、私がそれらをチェックしようとすると偽を返そうとするが、私がページをリフレッシュするとjsonの通知が表示される。しかし、私は私のIDの通知でdinamically私の配列を送信するが、私はそれを行うことはできますか?使用後のないまたはあなたがする必要がどのような私のID通知を受けても私の問題を解決する方法はありますか?
コントローラ通知
public function notification(){
$id = array(1,2,3,4);
$output = array_rand($id, 1);
$output_data = array('id' => $id[$output]);
$notifications = $this->notification->getNotifications($output_data);
if ($notifications) {
$data['product_id'] = $notifications->product_id;
$data['user_id'] = $notifications->user_id;
$data['message'] = $notifications->message;
$data['timestamp'] = $notifications->timestamp;
$data['update_count_notification'] = $this->notification->getCountNotification();
$data['success'] = true;
}else{
$data['success'] = false;
}
$this->json($data);
}
モデル通知
public function getNotifications($data){
$this->db->select('*');
$this->db->from('storelte_notifications');
$this->db->where('id',$data['id']);
$query = $this->db->get();
return $query->row();
}