0
I receive a request with the following object:
{
"member_id": 1,
"lista": [
{
"id": 1,
"member_id": 1,
"instituicao": "Teste Fund",
"data_inicio": "2018-04-25T06:00:00.000Z",
"data_termino": "2018-04-25T06:00:00.000Z",
"cidade": "Sao Paulo",
"estado": "SP",
"serie": "5",
"curso": null,
"tipo": "fundamental"
},
{
"id": 2,
"member_id": 1,
"instituicao": "Teste Sup",
"data_inicio": "2018-04-25T06:00:00.000Z",
"data_termino": "2018-04-25T06:00:00.000Z",
"cidade": "Belo Horizonte",
"estado": "MG",
"serie": null,
"curso": "Teologia",
"tipo": "superior"
}
]
}
The member_id I’m getting, but the 'List' always arrives.
Method sending the request:
public function update(AcademicoRequest $request)
{
$res = $request->all();
if ( $request->has('member_id') ) {
$dados_academicos = DB::table('academicos')->where('member_id', $request->member_id)->orderby('id')->get()->pluck('id')->unique()->all();
$this->destroy($dados_academicos);
}
$lista = $res['lista'];
foreach($lista as $value) {
Academico::create($value);
}
$result = array(
'message' => 'Os dados foram alterados com sucesso! ',
'data' => index($res->member_id),
'success' => true,
);
return response()->json($result);
}
What is the return of
var_dump($res)
?– Woss
Comes an empty [].
– user103979
So what is the return of
var_dump($request)
?– Woss
The return is huge, can not share.
– user103979
Have you tried
$request->input('key');
or$request->json('key')
?– Valdeir Psr
@Valdeirpsr, using $request->json('key') I got it. Thank you. Put the answer! ^^
– user103979