mercredi 27 juillet 2016

Laravel request int and string keys weird behaviour

Imagine - Laravel application, a get requst is mate.

The situation is, that a custom request, which has inputs with integer names, is made. In the custom request film I'm adding another field, lets say "fields". So at first the $request->all() returns

array(
     1 => "value1",
     5 => "value5",
     12 => "value12",
)

and after adding the new field $request->all() returns

array(
     1 => "value1",
     5 => "value5",
     12 => "value12",
     "fields" => array(
                      "key" => "value",
                 ),
)

Now the problem occurs - $request->get("fields") returns null.

$request->all() returns with fields.

$request->only(["fields"]) returns array with fields.

$request->exists("fields") returns true.

Why is it so?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aqhUIn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire