I have created following function in controller:
function beg($status_id = null) {
if(!empty($status_id)){
$conditions = array('winner_id >' => 0, 'Product.beginner' => '1', 'Product.status_id' => $status_id);
}else{
$conditions = array('winner_id >' => 0, 'Product.beginner' => '1');
}
$this->paginate = array('conditions' => $conditions, 'limit' => $this->appConfigurations['adminPageLimit'], 'order' => array('end_time' => 'asc'), 'contain' => array('Product' => array('Category'), 'Status', 'Winner'));
$this->set('products', $this->paginate('Product'));
$this->set('statuses', $this->Product->Status->find('list'));
$this->set('selected', $status_id);
$this->set('extraCrumb', array('title' => __('Product List', true), 'url' => 'beg'));
$this->render('beg');
}
I want to add one more condition in it, that is:
Search winner_id from Accounts table match with 'user_id' in accounts table, and only add Products in the list where winner Id is in Accounts table ('user_id' in accounts table).
Anybody know how to add condition with this $conditions = array('winner_id >' => 0, 'Product.beginner' => '1', 'Product.status_id' => $status_id);
I have added on more condition like below
$acc_id = $this->Account->find('all', array('Account.user_id'));
$conditions += array('Product.winner_id' => $acc_id);
But its not working, anybody please tell me where I am getting wrong