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
Post a Comment