samedi 30 mars 2019

How Update Group of rows with each row data for each row

I have some artist in my db and i want to increment follower field of artist.

Now i do this work with with foreach :

   $artist_should_increment=self::whereIn('id',[1,2,3])->get();

   foreach ($artist_should_increment as $artist_increment){
             $artist_increment->update(['followers'=>$artist_increment->followers+1]);
   }

But i want to update theme with chunk method of laravel! but i don't know how to do this work beacuse i don't know how to set $artist_increment->followers+1 for each row!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire