Skip to content

Instantly share code, notes, and snippets.

@jayaregalinada
Last active August 29, 2015 14:18
Show Gist options
  • Save jayaregalinada/e5559bf263250205c497 to your computer and use it in GitHub Desktop.
Save jayaregalinada/e5559bf263250205c497 to your computer and use it in GitHub Desktop.
Using switch method in getting Request parameters
////////////////////////////////////////////
// Assuming the URL is
// [http://example.com/request?abc=def]
// Will return in browser is a json
// { "abc": "def" }
// However when you try this,
// [http://example.com/request?capture=cat]
// This will return a text saying,
// "cat"
////////////////////////////////////////////
public function getRequest( Request $request )
{
switch ( key( $request->query() ) )
{
case 'capture':
dd( $request->input( 'capture' ) );
break;
default:
return $request->input();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment