Reputation: 2631
I want to use route()
to generate the urls.
e.g.
route('auth.facebook.getSocialAuth')
route('auth.twitter.getSocialAuth')
in routes.php
is there a way to dynamically generate the 'as' part of the route?
if CodeIgniter, what i would do is put $1 to get the dynamic {provider}
Route::get('connect/{provider}', ['as' => 'auth.$1.getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
How can i achieve that in Laravel?
Upvotes: 1
Views: 902
Reputation: 8340
You can add parameter to your route like this:
routes.php with parameter:
Route::get('connect/{provider}', ['as' => 'getSocialAuth', 'uses' => 'Auth\AuthController@getSocialAuth']);
route method with paramter:
route('getSocialAuth', [$provider]);
action method with parameter:
action('Auth\AuthController@getSocialAuth', [$provider]);
Upvotes: 4