I have a small cakePHP app that allows for user’s to login and be provided a session to give their status on an assigned project.
I am replacing the baked view portion of the add() function that asks which user to create a new status report for under with this line of code in the controller:
$this->data['Status']['user_id'] = $this->Auth->user('id');
I would like to do something similar in the index() function so that users could also, only see the their previous status reports and not any other users.
How would I attempt to filter the index() function?
function index() {
$this->Status->recursive = 0;
$this->set('statuses', $this->paginate());
}
Simply set your conditions in the paginate variable: