【发布时间】:2014-10-27 11:36:59
【问题描述】:
我无法找到 url 管理器背后的逻辑。任何人都可以告诉我有关在 Rest 模式中调用的给定 url。我的控制器中有太多带有单个参数的 get 方法。
这是我的原始网址:localhost/project/api/event/getevent/event_id/1
api 是模块 事件是控制器 getevent 是控制器动作名称 event_id 是参数1
我想将其转换为 Rest 模式 localhst/project/api/event/1
//更新代码..
所有都与同一个模型相关.......
//Search by Event id
public function actionByEventId(){
$model->byEventId();
}
//Retrieve user's events by User id
public function actionByUserId()
{
$model->userEvents();
}
//Search for event by code
public function actionByEventcode()
{
$model->byEventCode();
}
【问题讨论】:
-
你能添加你想怎么称呼他们吗?喜欢
localhst/project/api/event/1和localhst/project/api/user/1? -
不,我想要这样的 localhst/project/api/event/eventid/1 和 localhst/project/api/event/userid/1