【发布时间】:2013-03-18 06:14:53
【问题描述】:
我想,单行问题并不能很好地解释我在寻找什么。所以,这里是我所说的一个例子:(基于Laravel4 Routing documentation)
我为控制器创建路由的方式:
Route::get('user/profile', "UserController@profile" );
我为路由创建名称以便以后在生成 URL 时引用它的方式:
Route::get('user/profile', array('as' => 'profile', function()
{
//
}));
// Now I can use this
$url = URL::route('profile');
现在,显然您不想在 routes.php 中将控制器编写为函数,那么如何创建像第二个示例中的名称,但使用示例 1 中的控制器?
【问题讨论】: