Last active
August 29, 2015 14:18
-
-
Save jayaregalinada/e5559bf263250205c497 to your computer and use it in GitHub Desktop.
Using switch method in getting Request parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////// | |
// 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