jeudi 23 août 2018

Laravel 5.6 - Increment multiple same row columns in single statement?

Using eloquent model User, how can we increment 2 columns on the same row by 1 (in a single statement)?

This single statement works but only for incrementing a single column:

User::where('id',$userId)->increment('column1');

These following two attempts did not work:

User::where('id',$userId)->increment('column1')->increment('column2');

User::where('id',$userId)->increment(['column1','column2']);

Any ideas how to solve this in a single statement?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire