Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best practice accessing $_GET values in Laravel?

Is there a better way in accessing $_GET rather than the variable itself in Laravel or is that it?

I need multiple parameters for an API like /users?q=keyword&order=desc&limit=5

Is there a cleaner, safer and Laravel-ish way to access the $_GET values?

Thanks.

like image 479
jaggy Avatar asked Jul 20 '13 07:07

jaggy


1 Answers

You can use Input facade to reach those.

You can either do:

Input::all();

to retrieve all of the query parameters, or:

$q     = Input::get('q'); // will return 'keyword' for your example
$order = Input::get('order'); // will return 'desc' for your example
$limit = Input::get('limit'); // will return '5' for your example
like image 50
Umut Sirin Avatar answered Oct 13 '22 20:10

Umut Sirin