I get 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 empty.
Method that I send 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);
}