3

I have been checking out the Laravel source code a bit and I found this bit of code:

return $this->getRealMethod() == 'GET' ? $this->query : $this->request;

From:

https://github.com/illuminate/http/blob/master/Request.php#L668

This basically specifies that if the request method for a request is a 'GET' that the input method returns the query string parameters and otherwise gives you access to the POST variables.

This means that whenever I would make a post request I can not do the following to get a query string parameter named "date" for example:

$request->input('date')

I know it is useful to not merge POST and GET data since you get the possibility of overriding them but what is the exact motivation behind not allowing a user access to the query parameters when you make a POST request?

The way I see it, the input could have been split up into postInput and getInput for example to allow access to both without merging them. Of course you lose the ability that a generic input method gives you, but you gain a lot of flexibility.

Any thoughts on this?

Stephan-v
  • 19,255
  • 31
  • 115
  • 201
  • 5
    This feels a little off topic and might be better discussed on the laravel github repo – darryn.ten Nov 22 '16 at 14:54
  • You can get the query parameter via $request->query->get('date') and request body parameters via $request->request->get('parameter') – Gerry Nov 22 '16 at 14:55
  • @Gerry So I would have to use the input method for my POST variables and the query method to retrieve my GET parameters? – Stephan-v Nov 22 '16 at 14:59
  • 1
    I don't know why Laravel adds this `input` method, but that's how you retrieve the information from the underlying Symfony class and it still works in a Laravel context. Request::$query ~= $_GET, Request::$request ~= $_POST – Gerry Nov 22 '16 at 15:03
  • 1
    @darryn.ten moved it to the github repo, although it always feels weird to open an issue for a question like this. – Stephan-v Nov 22 '16 at 15:49

0 Answers0