基本的Laravel 4路由 [英] Basic Laravel 4 Routing
本文介绍了基本的Laravel 4路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用具有这种配置的参数来调用控制器:
I would like to call a controller with parameters with this kind of configuration:
Route::pattern('d', '[0-9]+');
Route::get('/{a}/{b}/{c}/{d}', function($a, $b, $c, $d)
{
// CALL A METHOD OF A CONTROLLER WITH PARAMETERS
});
推荐答案
只需调用控制器方法,如下所示:
Just call the controller method like this:
Route::get('/{a}/{b}/{c}/{d}', 'AnyController@itsMethod');
在控制器中:
class AnyController extends BaseController {
//...
public function itsMethod($a, $b, $c, $d) {
///proceed your params
}
//...
}
Laravel将路由变量(例如'/{a}/{b}/...
)作为参数传递给调用的控制器方法.
Laravel passes route-variables like '/{a}/{b}/...
as parameter(s) to the called controller-method.
这篇关于基本的Laravel 4路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文