【发布时间】:2015-10-18 09:08:54
【问题描述】:
这就是我的路线:
Router::scope('/', function ($routes) {
$routes->extensions(['json']);
$routes->resources('CustomerCompanies', [
'map' => [
'get_by_account' => [
'action' => 'get_by_account',
'method' => 'GET',
]
]
]);
这是我的方法get_by_account在CustomerCompaniesController.php内:
/**
* Pagination method by Customer Account id
*
* @param string|null $id Customer Account id.
* @return void Redirects to index.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function get_by_account($customer_account_id = null)
{
}
关系:
-
CustomerAccountshasManyCustomerCompanies -
CustomerCompanies属于CustomerAccounts
我想通过提供 CustomerAccount id 返回属于特定 CustomerAccount 的 CustomerCompanies 列表,然后返回 json 结果。
我是否需要更改 get_by_account 中的某些内容以指示参数?如果有,怎么做?
更新
这是我在文档中看到的:
【问题讨论】:
标签: rest cakephp cakephp-3.0