cyt*_*nny 8 php routes laravel laravel-5 laravel-5.3
在laravel 4.2和laravel 5.3中,在使用隐式控制器的路径中有一个选项.两个版本的语法相同.
Route::controller('myroute', 'myDearController');
Run Code Online (Sandbox Code Playgroud)
所以URL将是:
http://my.domain.com/myroute/function-name/parameter1/parameter2
Run Code Online (Sandbox Code Playgroud)
在laravel 4中,控制器看起来像:
//..... Some other controller related syntax ......
public function getFunctionName($parameter1, $parameter2) {
$inputs = Input::all();
dd($inputs);
}
//..... Some other controller related syntax ......
Run Code Online (Sandbox Code Playgroud)
但是,在laravel 5中,要获取GET输入,它会占用一个参数位置,所以我尝试做这样的事情:
//..... Some other controller related syntax ......
public function getFunctionName(Request $request, $parameter1, $parameter2) {
$inputs = $request->all();
dd($inputs);
}
//..... Some other controller related syntax ......
Run Code Online (Sandbox Code Playgroud)
但是,URL返回The site can't be reached.我尝试改变位置,
//..... Some other controller related syntax ......
public function getFunctionName( $parameter1, $parameter2, Request $request) {
$inputs = $request->all();
dd($inputs);
}
//..... Some other controller related syntax ......
Run Code Online (Sandbox Code Playgroud)
这是行不通的.我知道我可以将这一行添加Route::get('myroute/function-name/{$parameter1}/{$parameter2}', 'myDearController@getFunctionName')到路由文件中,但除了在路由文件中明确指定外,是否有默认方法可以这样做?
| 归档时间: |
|
| 查看次数: |
595 次 |
| 最近记录: |