I need to paginate a table where the I need to see only a project assigned to me, how can I achieve this?
What I have is this
//My Task Pagination
$this->paginate = array(
'Project' => array(
'limit' => $limit,
'contain' => array('ProjectReminderUser.user_id' => $this->Session->read('Auth.User.id')),
'conditions' => array(
'User.group_id' => $this->Session->read('Auth.User.group_id'),
'Project.project_status_id' => PROJECT_STATUS_OPEN,
),
)
);
$this->set('myTasks', $this->paginate('Project'));
//debug($this->paginate('Project'));
but seems like the contain does not work at all. The result of debug looks like this
array(
(int) 0 => array(
'Project' => array(
'id' => '9',
'project_type_id' => '0',
'contact_id' => '2',
'company_id' => '6',
),
'ProjectReminderUser' => array(
(int) 0 => array(
'id' => '11',
'user_id' => '2',
'project_id' => '9'
)
),
(int) 1 => array(
'Project' => array(
'id' => '1',
'project_type_id' => '0',
'contact_id' => '1',
'company_id' => '3',
),
'ProjectReminderUser' => array(
(int) 0 => array(
'id' => '2',
'user_id' => '1',
'project_id' => '1'
),
(int) 1 => array(
'id' => '1',
'user_id' => '2',
'project_id' => '1'
)
),
)
)
So what I would like to achieve is to have the pagination only show array index 1, because the ProjectReminderUser have user_id = 1 (a project that is assigned to me)
something like that. I tried to use containable but it does not work, maybe something wrong with the way I did it?