I have a cakephp2 application where users login based on their credentials on a db. Authentication & Authorizations work fine.
I have a notes table, in which users's notes are stored. Each user can have many notes.
On one page I need to extract all the notes of the logged in user.
I have created a note model :
class Note extends AppModel {
public $name = 'Note';
public $belongsTo = 'User';
}
and in my user model I have:
class User extends AppModel {
public $name = 'User';
public $displayField = 'name';
public $hasMany = 'Note';....
In the usercontroller i have created:
public function getnotes($id = null) {
$this->User->id = $id;
}
but no matter what find statement I run, I can't get only the notes for the specific user. I run debug($id) and I get false on screen, so obviously the current user id is not being recognized.
I have to list all the notes of a user then link to each individual notes page.