I have two models named message.php and user.php
In message.php, I have following method that counts #no of messages of verified users.
<?php
class Message extends AppModel {
...
...
...
function getInboxCount($userId) {
// Here I want to get list of ids of verified users. It means I need to use User model for this. How is it possible?
// $ids = $this->User->find('list', array('conditions' => array('User.status' => 'verified'))); Will this work?
}
}
?>
So how can I use User model in Message model?
If the two models are associated in any way (Message belongsTo User or so), you can access it simply with:
If they’re not associated, you can import any other model at any time using: