你好,我正在使用睡觉和拉威尔创建一个应用编程接口,下面是第this篇文章.
Everything works well as expected.
Now, I want to map a GET request to recognise a variable using "?".
例如:domain/api/v1/todos?start=1&limit=2
.
以下是我的routes.php
周年纪念的内容:
Route::any('api/v1/todos/(:num?)', array(
'as' => 'api.todos',
'uses' => 'api.todos@index'
));
我的controllers/api/todos.php
:
class Api_Todos_Controller extends Base_Controller {
public $restful = true;
public function get_index($id = null) {
if(is_null($id)) {
return Response::eloquent(Todo::all(1));
} else {
$todo = Todo::find($id);
if (is_null($todo)) {
return Response::json('Todo not found', 404);
} else {
return Response::eloquent($todo);
}
}
}
}
如何使用"?"获取参数?