php - Laravel 5 - Change all values in a Column of a table -


i have table column called "estado" , want change column in 1 shot.

this right method? faster one?

$vendedor = vendedor::with('produtos')->find( $idvendedor );      foreach ( $vendedor->produtos $produto ) {         $produto->pivot->estado = $novoestado;     }; 

the column want change "estado". there's way without foreach?

the simplest use query builder (instead of model)

db::table('table_name')->where('vendedor_id', $idvendedor)->update('estado', $novoestado); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -