我有一条路线 - 让我们称之为统计数据.这是我的路由目前的样子:
Route::get('stats', 'StatsController@index'); Route::get('stats/{query}', 'StatsController@store');
我的目标是显示有人访问/统计数据的统计数据,并在有人访问类似于/ stats的网址时存储统计数据?name = John&device = Android.
如果有一个查询字符串附加到我的命名空间统计信息,我将如何路由?
像这样的东西?
Route::get('stats/?name=*&device=*', 'StatsController@store');
Javi Stolz.. 6
routes.php文件
Route::get('stats', 'StatsController@index');
StatsController
public function index() { if(Input::has('name') and Input::has('device'))) return $this->store(); // Show stat ... } public function store() { $input = Input::only('name', 'device'); // Store stat ... }
虽然它似乎是一个RESTFUL控制器的完美场景.无论谁发送输入,都应该使用POST请求
routes.php文件
Route::get('stats', 'StatsController@index');
StatsController
public function index() { if(Input::has('name') and Input::has('device'))) return $this->store(); // Show stat ... } public function store() { $input = Input::only('name', 'device'); // Store stat ... }
虽然它似乎是一个RESTFUL控制器的完美场景.无论谁发送输入,都应该使用POST请求