1

I have route like this. I am trying to check if route param social is either facebook, google or twitter.

Route::get('/login/{social}', 'Auth\LoginController@loginSocial')
->where('social',["facebbok","google","twitter"]);

Above route is not working. It asks for regex. Please help.

How to check this ?

GRESPL Nagpur
  • 1,996
  • 3
  • 18
  • 38

4 Answers4

3

Try this:

Route::get('/login/{social}', 'Auth\LoginController@loginSocial')
->where('social','(facebook|google|twitter)');
Mustofa Rizwan
  • 10,009
  • 2
  • 25
  • 42
0

The where method on a route instance accepts the name of the parameter and a regular expression, your second parameter isn't a regular expression:

Route::get('/login/{social}', 'Auth\LoginController@loginSocial')
->where('social','(facebook|google|twitter)');

Here is a valid RegExp

jeanj
  • 1,931
  • 11
  • 21
0

You haven't stated what the method signature of the ->where but at a guess:

Route::get('/login/{social}', 'Auth\LoginController@loginSocial')
->where('social', "/^(facebook|google|twitter)$/i");
John Joseph
  • 901
  • 5
  • 13
0

Hope this condition will helpful for you.

Route::get('/login/{social}','Auth\LoginController@loginSocial')
    ->where('social', 'facebook|google|twitter');
Petter Friberg
  • 20,644
  • 9
  • 57
  • 104
Soniya Basireddy
  • 359
  • 2
  • 10