[Vuejs]-How to update data in a table in an array form in Vue.js

0👍

Just move your update query inside the foreach loop:

foreach($data['data'] as $x => $emp_key) {

     DB::table('employee')->where('emp_key',  $emp_key)->update([
        'group_code' => $id,
    ]);
 }

What your previous code was doing was that the $emp_key variable was only storing the last value in your loop thus it was the only one being updated by your query

Leave a comment