I know it's a good idea to put all data-related logic in your models in CakePHP, but what would you say about keeping every Model::find() and its particular params in the model? Is this good practice, or just taking things too far?
For example, is this:
PostsController:
function index() {
$posts = $this->Post->getLatest();
$this->set(compact('posts'));
}
Post model:
function getLatest() {
$params = array(
'conditions' => array('published' => 1),
'limit' => 5,
'order' => 'publish_date DESC'
);
return $this->find('all', $params);
}
Better than this:
PostsController:
function index() {
$params = array(
'conditions' => array('published' => 1),
'limit' => 5,
'order' => 'publish_date DESC'
);
$posts = $this->Post->find('all', $params);
$this->set(compact('posts'));
}
Any thoughts? Which is better architecturally?