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
  • 2,048
  • 3
  • 20
  • 40

4 Answers4

3

Try this:

Route::get('/login/{social}', 'Auth\LoginController@loginSocial')
->where('social','(facebook|google|twitter)');
Mustofa Rizwan
  • 10,215
  • 2
  • 28
  • 43
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
  • 2,106
  • 13
  • 22
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
  • 921
  • 5
  • 14
0

Hope this condition will helpful for you.

Route::get('/login/{social}','Auth\LoginController@loginSocial')
    ->where('social', 'facebook|google|twitter');
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Soniya Basireddy
  • 369
  • 2
  • 10