Laravel 5 get only GET or POST params from request

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.


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


Follow these instructions to extend the Laravel Request class with your own:

https://stackoverflow.com/a/30840179/517371

Then, in your own Request class, copy the input() method from Illuminate\Http\Request and remove + $this->query->all():

public function input($key = null, $default = null)
{
    $input = $this->getInputSource()->all();

    return data_get($input, $key, $default);
}

Bingo! Now in a POST request, Request::query() returns the query (URL) parameters, while Request::input() only returns parameters from the form / multipart / JSON / whatever input source.