4 months ago

How do I create a new request overwriting json()->all()

Posted 4 months ago by spacedog4

I'm developing an exporter, when I'm exporting data to an table I pass all the data trought post, inside a records parameter and the server discover if it needs to update or create a new row.

    "records" => "[{\"foo\":\"bar\"}]"

I get this records parameter and create another Request cause inside it can have child relationships, so I create another request to pass trought the validation.

$created_request = new NewRequest(
    [], // query
    ["foo" => "bar"], // request
    [] // attributes

The problem is, if I make a normal request, when I call $created_request->all() it will return me ["foo" => "bar"], correct, but if I make a json request, it will return me the old data "records" => "[{\"foo\":\"bar\"}]"

Basic, doing my research, I discovered that in a normal request, $created_request->all() will return $created_request->query->all() and $created_request->request->all(), on the other hand in a json request, $created_request->all() will return $created_request->json()->all() that always return the old data, how do I create a new request overwriting json()->all()

Please sign in or create an account to participate in this conversation.