I want to pass some data on $request in a way that does the same when you send something through the form

Asked

Viewed 26 times

0

$data = $request->all();
    $data['id_cliente']= $sistemas->id_cliente;
    $data['id_sistema']= $sistemas->id_sistema;
    $data['id_versao_atual']= $sistemas->id_versao_atual;
    $data['id_versao_anterior']= $sistemas->id_versao_anterior;
    $data['data_ult_atualizacao']=  $sistemas->data_hora_ultima_verificacao;
    $data['situacao']= 0;
    $request->request->parameters = $data;

only it shows the following error

Exception has occurred. Error: Cannot access protected Property Symfony Component Httpfoundation Parameterbag::$Parameters

1 answer

0

You can do this using the function merge() of own request.

$data = [];
$data['id_cliente'] = $sistemas->id_cliente;
$data['id_sistema'] = $sistemas->id_sistema;
$data['id_versao_atual'] = $sistemas->id_versao_atual;
$data['id_versao_anterior'] = $sistemas->id_versao_anterior;
$data['data_ult_atualizacao'] =  $sistemas->data_hora_ultima_verificacao;
$data['situacao'] = 0;

$request->merge($data);

  • managed to receive this parameter in my put function protected Function PUT(Request $request,$endpoint){ $http = new Client(); $Response = $http->put( $endpoint,[$request],[ 'headers' => [ 'Accept' => 'application/json', 'Authorization' => 'Bearer '.$token=$request->Session()->get('token'), 'Content-Type' => 'application/x-www-form-urlencoded', 'Content-Type' => 'application/json' ], ]); $body = $Response->getBody(); }

  • Cool, but if possible test this other solution, will it solve your problem more simply.

  • you misunderstood me, to be able to solve with your solution, but with another doubt

  • to send and $request->() and to receive is $request-> ... what

Browser other questions tagged

You are not signed in. Login or sign up in order to post.