I'm trying to use the new CakePHP 3.0, and I have a little problem when I figure out where to put the requests.
Lets say that we have something like this, right from their documentation.
$articles = $this->Articles->find('all', [
'fields' => ['id', 'title'],
'conditions' => [
'OR' => ['title' => 'Cake', 'author_id' => 1],
'published' => true
],
'contain' => ['Authors'],
'order' => ['title' => 'DESC'],
'limit' => 10,
]);
Where can I put this code? In my controller class or in the model folder.
If I need to put this code in my controller class, and in the future I would like to reuse this request. Do I need to rewrite the request in another controller?
If in the model folder, in which folder do I insert it? Behavior, entity or table? and how will i use it?
thank
source
share