php - Not able to update multiple data using eloquent -


i using laravel build application. also, using eloquent orm.

there 2 tables:

meetings - id(pk), name, meeting_with, meeting_on user_meetings - id, meeting_id (fk -meetings (id) ), user_id 
      {       "data" : {         "meeting_details" : {           "id" : 8,           "name" : "client",           "meeting_with" : "ceo",           "meeting_on" : 1431588871          },         "user_details" : {                 "2" : "second user",                 "1" : "first user"           }       }     }  

this json post getting. need update in 2 tables - meetings , user_meetings

i able update meetings table, not able update user_meetings table.

foreach($meetings_data['data']['user_details'] $user_id => $user_name) {             $update_array_set['user_id'] = $user_id;             $user_meeting_result = usermeetingdetails::where('meeting_id', '=', $meeting_id)->update($update_array_set); } 

i user_id user_details.

so, if there 2 users corresponding 1 meeting_id, , if try update one, updates that, keeps second entry. and, if json has 1 object under user_details, there needs 1 object in database corresponding meeting_id

read section of documentation again: http://laravel.com/docs/5.0/eloquent#insert-update-delete

if set relationships correctly in model, can use $model->push() , update relations well.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -