Routing Laravel 5动态命名路由
我想使用Routing Laravel 5动态命名路由,routing,laravel-5,Routing,Laravel 5,我想使用route()生成URL e、 g route('auth.facebook.getSocialAuth') route('auth.twitter.getSocialAuth') 在routes.php中,是否有一种方法可以动态生成路由的“as”部分 如果是CodeIgniter,我要做的是投入$1来获取动态{provider} Route::get('connect/{provider}', ['as' => 'auth.$1.getSocialAuth', 'uses' =&
route()
生成URL
e、 g
route('auth.facebook.getSocialAuth')
route('auth.twitter.getSocialAuth')
在routes.php
中,是否有一种方法可以动态生成路由的“as”部分
如果是CodeIgniter,我要做的是投入$1来获取动态{provider}
Route::get('connect/{provider}', ['as' => 'auth.$1.getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
如何在Laravel中实现这一点?您可以像这样向路线添加参数: 带有参数的routes.php:
Route::get('connect/{provider}', ['as' => 'getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
action('Auth\AuthController@getSocialAuth', [$provider]);
带参数的路由方法:
route('getSocialAuth', [$provider]);
带参数的操作方法:
Route::get('connect/{provider}', ['as' => 'getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
action('Auth\AuthController@getSocialAuth', [$provider]);
您可以按如下方式向管线添加参数: 带有参数的routes.php:
Route::get('connect/{provider}', ['as' => 'getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
action('Auth\AuthController@getSocialAuth', [$provider]);
带参数的路由方法:
route('getSocialAuth', [$provider]);
带参数的操作方法:
Route::get('connect/{provider}', ['as' => 'getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
action('Auth\AuthController@getSocialAuth', [$provider]);