I have an angular post request going to a laravel controller function inserting into a db. The payload looks like this:
[
{"id":1,"utid":"ABC","name":"Introduction","docId":1,"position":1},
{"id":2,"utid":"DEF","name":"Chapter One","docId":1,"position":2},
{"utid":"GHI","name":"asd","docId":1,"position":3}
]
How do I extract the inputs and assign them correctly to the database command. I imagine something with foreach but I don't know the synthax. Can anyone help me?
foreach($topics as $topic => $insert )
{
DB::table('topics')->insert(array(
array(
'utid' => Input::json('utid'),
'name' => Input::json('name'),
'docId' => Input::json('docId'),
'position' => Input::json('position')
)
));
}