【发布时间】:2016-06-26 08:34:34
【问题描述】:
我正在模型中创建一个函数来查找所有相关服务。
ServiceCategory.php中的函数
class ServiceCategory extends Entity
{
public function relatedServices($id)
{
return $this->find('all', [
'conditions' => [
'where' => [
'id !=' => $id
],
'limit' => 5
]
]);
}
}
并致电ServiceCategoriesController.php
public function view($id = null)
{
$serviceCategory = $this->ServiceCategories->get($id, [
'contain' => ['Services']
]);
$relatedServices = $this->ServiceCategories->relatedServices($id);
$this->set('serviceCategory', $serviceCategory);
$this->set('relatedServices', $relatedServices);
$this->set('_serialize', ['serviceCategory']);
}
但它给了Unknown method 'relatedServices'
我做错了什么吗?
【问题讨论】:
标签: cakephp model cakephp-3.0