php - Update existing data otherwise insert new data -


i new in laravel.first have have inserted form data database .then have fetched data array. inserted data new database. when every time insert form data, in second database data inserted multiple time.my code given below:

foreach($result $res) {     $res1 = userlist::firstorcreate($res);  } 

here array. if same data in database, want update array new value database

the method want use updateorcreate

model::updateorcreate(   ['needle' => $value],   ['field1' => 'value1', 'field2' => 'value2'] ); 

hope help.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -