Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 get only GET or POST params from request

I can access request params using Request::input() or Request::all().

The problem is that my request includes both GET and POST params, but only GET ones are used to calculate signature.

Is there a way to retrieve only a set of GET or a set of POST params from request in Laravel 5.1?

Or going with $_GET and $_POST is my only option here?

Thank you.

like image 258
MaGnetas Avatar asked Jul 23 '15 11:07

MaGnetas


2 Answers

You can use Request::query() to get only GET parameters. Keep in mind that there are no guaranties about consistency in the order of parameters you get from GET, so you might need to sort the array before calculating the signature - depending on how you calculate the signature.

like image 198
jedrzej.kurylo Avatar answered Oct 31 '22 23:10

jedrzej.kurylo


If you need something straightforward you can just use the global helper:

$pathData = request()->path(); <br />
$queryData = request()->query(); <br />
$postData = array_diff(request()->all(), request()->query());

https://laravel.com/docs/5.6/requests

like image 41
aamuller Avatar answered Nov 01 '22 00:11

aamuller